{"name":"bare-stream","version":"2.11.0","author":{"name":"Holepunch"},"license":"Apache-2.0","_id":"bare-stream@2.11.0","maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"kasperisager","email":"kasperisager@hey.com"},{"name":"yassernasc","email":"dev@yasser.email"}],"homepage":"https://github.com/holepunchto/bare-stream#readme","bugs":{"url":"https://github.com/holepunchto/bare-stream/issues"},"dist":{"shasum":"12f82a5624658d05356ace4b7fd698f0fb402a84","tarball":"http://registry-npm.ywwl.com/bare-stream/download/bare-stream-2.11.0.tgz","fileCount":9,"integrity":"sha512-Y/+iQ49fL3rIn6w/AVxI/2+BRrpmzJvdWt5Jv8Za6Ngqc6V227c+pYjYYgLdpR3MwQ9ObVXD0ZrqoBztakM0rw==","signatures":[{"sig":"MEQCIFTloehsSYpxdBMzFzEEmyoz9wNPuTJCsx4L7RPnMLZgAiBasxRUu2C5O/743blVd03oVjQYxHNo0vRkUoWqcES2mg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43229,"size":9799,"noattachment":false,"key":"/bare-stream/-/bare-stream-2.11.0.tgz"},"types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.js"},"./web":{"types":"./web.d.ts","default":"./web.js"},"./global":"./global.js","./package":"./package.json","./promises":"./promises.js"},"gitHead":"4ce5ff9997b59849a3c9ccd1152be0f060ddc1bf","scripts":{"test":"prettier . --check && bare test.js"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"repository":{"url":"git+https://github.com/holepunchto/bare-stream.git","type":"git"},"_npmVersion":"11.10.1","description":"Streaming data for JavaScript","directories":{},"_nodeVersion":"25.7.0","dependencies":{"teex":"^1.0.1","streamx":"^2.25.0"},"_hasShrinkwrap":false,"devDependencies":{"brittle":"^3.5.2","prettier":"^3.3.3","bare-buffer":"^3.0.0","bare-events":"^2.5.4","bare-abort-controller":"^1.1.0","prettier-config-holepunch":"^2.0.0"},"peerDependencies":{"bare-buffer":"*","bare-events":"*","bare-abort-controller":"*"},"peerDependenciesMeta":{"bare-buffer":{"optional":true},"bare-events":{"optional":true},"bare-abort-controller":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/bare-stream_2.11.0_1774443456099_0.43000110166191674","host":"s3://npm-registry-packages-npm-production"},"readme":"# bare-stream\n\nStreaming data for JavaScript. The classic Node.js-style stream classes are backed by `streamx` (<https://github.com/mafintosh/streamx>) while a `node:stream/web`-compatible implementation of the WHATWG Streams Standard is also provided.\n\n```\nnpm i bare-stream\n```\n\n## Usage\n\n```js\nconst { Readable } = require('bare-stream')\n\nconst stream = new Readable({\n  read(size) {\n    // Push data, then push `null` to signal the end\n    this.push('hello')\n    this.push('world')\n    this.push(null)\n  }\n})\n\nstream.on('data', (data) => console.log(data))\n```\n\n## API\n\nThe classic stream classes and helpers are exported from `bare-stream` and follow the Node.js `stream` API. See <https://nodejs.org/api/stream.html> and <https://github.com/mafintosh/streamx> for the complete behavior; the additions and differences specific to this module are documented below.\n\n#### `const stream = new Readable([options])`\n\nA readable stream. Options include:\n\n```js\noptions = {\n  eagerOpen: false,\n  highWaterMark: 16384,\n  encoding: null,\n  signal: null,\n  open(cb) {},\n  read(size) {},\n  predestroy() {},\n  destroy(err, cb) {}\n}\n```\n\nIf `encoding` is set, emitted data is decoded to strings using that encoding. If `signal` is an `AbortSignal`, the stream is destroyed when the signal aborts.\n\n#### `stream.closed`\n\n`true` when the stream is no longer readable.\n\n#### `stream.errored`\n\nThe error the stream was destroyed with, or `null`.\n\n#### `stream.push(data[, encoding])`\n\nPush `data` into the stream's internal buffer. If `data` is a string, it is encoded to a `Buffer` using `encoding`, defaulting to `'utf8'`. Push `null` to signal the end of the stream.\n\n#### `stream.unshift(data[, encoding])`\n\nLike `stream.push()` but prepends `data` to the internal buffer so it is read before any already buffered data.\n\n#### `Readable.from(data[, options])`\n\nCreate a readable stream from `data`, which may be a value, an array of values, or an async iterable.\n\n#### `Readable.isBackpressured(stream)`\n\n#### `Readable.isPaused(stream)`\n\n#### `Readable.fromWeb(readableStream[, options])`\n\nConvert a web `ReadableStream` into a `Readable`. Options include:\n\n```js\noptions = {\n  encoding: null,\n  signal: null\n}\n```\n\n#### `Readable.toWeb(readable[, options])`\n\nConvert a `Readable` into a web `ReadableStream`. Options include:\n\n```js\noptions = {\n  strategy: null\n}\n```\n\n`strategy` is a custom queuing strategy passed through to the `ReadableStream` constructor.\n\n#### `const stream = new Writable([options])`\n\nA writable stream. Options include:\n\n```js\noptions = {\n  eagerOpen: false,\n  signal: null,\n  open(cb) {},\n  write(data, encoding, cb) {},\n  writev(batch, cb) {},\n  final(cb) {},\n  predestroy() {},\n  destroy(err, cb) {}\n}\n```\n\n#### `stream.closed`\n\n`true` when the stream is no longer writable.\n\n#### `stream.errored`\n\nThe error the stream was destroyed with, or `null`.\n\n#### `stream.write(data[, encoding][, cb])`\n\nWrite `data` to the stream. If `data` is a string, it is encoded using `encoding`, defaulting to `'utf8'`. Returns `false` if the stream is backpressured. The optional `cb` is called once the write has drained.\n\n#### `stream.end([data][, encoding][, cb])`\n\nSignal that no more data will be written. If `data` is provided it is written first. The optional `cb` is called once the stream has finished.\n\n#### `Writable.isBackpressured(stream)`\n\n#### `Writable.drained(stream)`\n\nReturns a promise that resolves once the stream has drained.\n\n#### `Writable.fromWeb(writableStream[, options])`\n\nConvert a web `WritableStream` into a `Writable`. Options include:\n\n```js\noptions = {\n  signal: null\n}\n```\n\n#### `Writable.toWeb(writable)`\n\nConvert a `Writable` into a web `WritableStream`.\n\n#### `const stream = new Duplex([options])`\n\nA stream that is both readable and writable. Accepts the combined options of `Readable` and `Writable`.\n\n#### `Duplex.fromWeb({ readable, writable }[, options])`\n\nConvert a pair of web `ReadableStream` and `WritableStream` into a `Duplex`.\n\n#### `Duplex.toWeb(duplex)`\n\nConvert a `Duplex` into a `{ readable, writable }` pair of web streams.\n\n#### `const stream = new Transform([options])`\n\nA duplex stream where output is computed from input. Options include the `Duplex` options plus:\n\n```js\noptions = {\n  transform(data, encoding, cb) {},\n  flush(cb) {}\n}\n```\n\nIf no `transform` is provided, the stream acts as a pass-through.\n\n#### `const stream = new PassThrough([options])`\n\nA `Transform` that forwards input to output unchanged.\n\n#### `const [a, b] = duplexPair([options])`\n\nCreate a pair of linked `Duplex` streams. Data written to `a` is readable from `b` and vice versa. `options` are passed to each side.\n\n#### `stream.pipeline(streams[, cb])`\n\n#### `stream.pipeline(...streams[, cb])`\n\nPipe a series of streams together, propagating errors and cleaning up on completion. `streams` is a `Readable` source, zero or more `Duplex` transforms, and a `Writable` destination. Returns the destination stream. `cb` is called when the pipeline finishes or errors.\n\n#### `const detach = stream.finished(stream[, options], cb)`\n\nInvoke `cb` once `stream` is no longer readable or writable, or has errored. Returns a function that detaches the listeners. Options include:\n\n```js\noptions = {\n  cleanup: false\n}\n```\n\nWhen `cleanup` is `true`, the listeners are detached automatically once `cb` runs.\n\n#### `stream.addAbortSignal(signal, stream)`\n\nDestroy `stream` when `signal` aborts, using `signal.reason` as the destruction error. Returns `stream`.\n\n#### `stream.isStream(stream)`\n\n#### `stream.isEnding(stream)`\n\n#### `stream.isEnded(stream)`\n\n#### `stream.isFinishing(stream)`\n\n#### `stream.isFinished(stream)`\n\n#### `stream.isDisturbed(stream)`\n\n#### `stream.isErrored(stream)`\n\n#### `stream.isReadable(stream)`\n\n#### `stream.isWritable(stream)`\n\nState predicates for streams. Each returns a boolean.\n\n#### `const err = stream.getStreamError(stream[, options])`\n\nReturn the error a stream was destroyed with, or `null`. Options include:\n\n```js\noptions = {\n  all: false\n}\n```\n\n### Promises\n\nA promise-based variant of `pipeline` is available from `bare-stream/promises`.\n\n#### `const stream = await pipeline(streams)`\n\n#### `const stream = await pipeline(...streams)`\n\nLike `stream.pipeline()` but returns a promise that resolves with the destination stream once the pipeline finishes, or rejects on error.\n\n### Web\n\nA `node:stream/web`-compatible implementation of the WHATWG Streams Standard is available from `bare-stream/web`. See <https://streams.spec.whatwg.org> for the complete behavior.\n\n#### `const stream = new ReadableStream([underlyingSource][, queuingStrategy])`\n\nA web readable stream. `underlyingSource` may provide `start`, `pull`, and `cancel` methods, or be an existing `streamx` stream to wrap. `queuingStrategy` defaults to a `CountQueuingStrategy`.\n\n#### `stream.locked`\n\n#### `stream.getReader()`\n\nAcquire a `ReadableStreamDefaultReader`. Throws if the stream is already locked.\n\n#### `stream.cancel([reason])`\n\n#### `stream.tee()`\n\nSplit the stream into two independent `ReadableStream` branches.\n\n#### `stream.pipeTo(destination)`\n\nPipe the stream to a `WritableStream`, returning a promise that resolves once piping completes.\n\n#### `ReadableStream.from(iterable)`\n\nCreate a `ReadableStream` from an iterable or async iterable.\n\n#### `const reader = new ReadableStreamDefaultReader(stream)`\n\nA reader over a `ReadableStream`, exposing `closed`, `read()`, `releaseLock()`, and `cancel([reason])`.\n\n#### `const controller = new ReadableStreamDefaultController(stream)`\n\nThe controller passed to `start` and `pull`, exposing `desiredSize`, `enqueue(data)`, `close()`, and `error([err])`.\n\n#### `const stream = new WritableStream([underlyingSink][, queuingStrategy])`\n\nA web writable stream. `underlyingSink` may provide `start`, `write`, `close`, and `abort` methods, or be an existing `streamx` stream to wrap.\n\n#### `stream.locked`\n\n#### `stream.getWriter()`\n\nAcquire a `WritableStreamDefaultWriter`. Throws if the stream is already locked.\n\n#### `stream.abort([reason])`\n\n#### `stream.close()`\n\n#### `const writer = new WritableStreamDefaultWriter(stream)`\n\nA writer over a `WritableStream`, exposing `desiredSize`, `closed`, `ready`, `write(chunk)`, `releaseLock()`, `close()`, and `abort([reason])`.\n\n#### `const controller = new WritableStreamDefaultController(stream)`\n\nThe controller passed to `start` and `write`, exposing `error([err])`.\n\n#### `const stream = new TransformStream([transformer][, writableStrategy][, readableStrategy])`\n\nA web transform stream. `transformer` may provide `start`, `transform`, and `flush` methods. Exposes `readable` and `writable` properties.\n\n#### `const controller = new TransformStreamDefaultController(stream)`\n\nThe controller passed to `start`, `transform`, and `flush`, exposing `desiredSize`, `enqueue(data)`, `error([err])`, and `terminate()`.\n\n#### `const strategy = new CountQueuingStrategy([options])`\n\nA queuing strategy that counts each chunk as size `1`. Options include:\n\n```js\noptions = {\n  highWaterMark: 1\n}\n```\n\n#### `const strategy = new ByteLengthQueuingStrategy([options])`\n\nA queuing strategy that measures each chunk by its `byteLength`. Options include:\n\n```js\noptions = {\n  highWaterMark: 16384\n}\n```\n\n#### `isReadableStream(value)`\n\n#### `isReadableStreamErrored(stream)`\n\n#### `isReadableStreamDisturbed(stream)`\n\n#### `isWritableStream(value)`\n\n#### `isTransformStream(value)`\n\nPredicates for web streams. Each returns a boolean.\n\n### Global\n\nRequiring `bare-stream/global` installs the web stream classes as globals, matching the browser and Node.js environments:\n\n```js\nrequire('bare-stream/global')\n\nconst stream = new ReadableStream()\n```\n\n## License\n\nApache-2.0\n","publish_time":1774443456248,"_cnpm_publish_time":1774443456248,"dist-tags":{"latest":"2.13.4"}}