Comparing version 3.0.1 to 3.1.0
12
index.js
'use strict' | ||
const EE = require('events') | ||
const Stream = require('stream') | ||
const Yallist = require('yallist') | ||
@@ -48,3 +49,3 @@ const SD = require('string_decoder').StringDecoder | ||
module.exports = class Minipass extends EE { | ||
module.exports = class Minipass extends Stream { | ||
constructor (options) { | ||
@@ -529,7 +530,8 @@ super() | ||
static isStream (s) { | ||
return !!s && (s instanceof Minipass || s instanceof EE && ( | ||
typeof s.pipe === 'function' || // readable | ||
(typeof s.write === 'function' && typeof s.end === 'function') // writable | ||
)) | ||
return !!s && (s instanceof Minipass || s instanceof Stream || | ||
s instanceof EE && ( | ||
typeof s.pipe === 'function' || // readable | ||
(typeof s.write === 'function' && typeof s.end === 'function') // writable | ||
)) | ||
} | ||
} |
{ | ||
"name": "minipass", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "minimal implementation of a PassThrough stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,18 +10,18 @@ # minipass | ||
Supports pipe()ing (including multi-pipe() and backpressure | ||
transmission), buffering data until either a `data` event handler or | ||
`pipe()` is added (so you don't lose the first chunk), and most other | ||
cases where PassThrough is a good idea. | ||
Supports pipe()ing (including multi-pipe() and backpressure transmission), | ||
buffering data until either a `data` event handler or `pipe()` is added (so | ||
you don't lose the first chunk), and most other cases where PassThrough is | ||
a good idea. | ||
There is a `read()` method, but it's much more efficient to consume | ||
data from this stream via `'data'` events or by calling `pipe()` into | ||
some other stream. Calling `read()` requires the buffer to be | ||
flattened in some cases, which requires copying memory. | ||
There is a `read()` method, but it's much more efficient to consume data | ||
from this stream via `'data'` events or by calling `pipe()` into some other | ||
stream. Calling `read()` requires the buffer to be flattened in some | ||
cases, which requires copying memory. | ||
There is also no `unpipe()` method. Once you start piping, there is | ||
no stopping it! | ||
There is also no `unpipe()` method. Once you start piping, there is no | ||
stopping it! | ||
If you set `objectMode: true` in the options, then whatever is written | ||
will be emitted. Otherwise, it'll do a minimal amount of Buffer | ||
copying to ensure proper Streams semantics when `read(n)` is called. | ||
If you set `objectMode: true` in the options, then whatever is written will | ||
be emitted. Otherwise, it'll do a minimal amount of Buffer copying to | ||
ensure proper Streams semantics when `read(n)` is called. | ||
@@ -32,7 +32,7 @@ `objectMode` can also be set by doing `stream.objectMode = true`, or by | ||
This is not a `through` or `through2` stream. It doesn't transform | ||
the data, it just passes it right through. If you want to transform | ||
the data, extend the class, and override the `write()` method. Once | ||
you're done transforming the data however you want, call | ||
`super.write()` with the transform output. | ||
This is not a `through` or `through2` stream. It doesn't transform the | ||
data, it just passes it right through. If you want to transform the data, | ||
extend the class, and override the `write()` method. Once you're done | ||
transforming the data however you want, call `super.write()` with the | ||
transform output. | ||
@@ -51,2 +51,3 @@ For some examples of streams that extend Minipass in various ways, check | ||
- [treport](http://npm.im/tap) | ||
- [minipass-fetch](http://npm.im/minipass-fetch) | ||
@@ -258,3 +259,4 @@ ## Differences from Node.js Streams | ||
It's a stream! Use it like a stream and it'll most likely do what you want. | ||
It's a stream! Use it like a stream and it'll most likely do what you | ||
want. | ||
@@ -287,27 +289,26 @@ ```js | ||
base Minipass class, the same data will come out.) Returns `false` if | ||
the stream will buffer the next write, or true if it's still in | ||
"flowing" mode. | ||
the stream will buffer the next write, or true if it's still in "flowing" | ||
mode. | ||
* `end([chunk, [encoding]], [callback])` - Signal that you have no more | ||
data to write. This will queue an `end` event to be fired when all the | ||
data has been consumed. | ||
* `setEncoding(encoding)` - Set the encoding for data coming of the | ||
stream. This can only be done once. | ||
* `setEncoding(encoding)` - Set the encoding for data coming of the stream. | ||
This can only be done once. | ||
* `pause()` - No more data for a while, please. This also prevents `end` | ||
from being emitted for empty streams until the stream is resumed. | ||
* `resume()` - Resume the stream. If there's data in the buffer, it is | ||
all discarded. Any buffered events are immediately emitted. | ||
* `resume()` - Resume the stream. If there's data in the buffer, it is all | ||
discarded. Any buffered events are immediately emitted. | ||
* `pipe(dest)` - Send all output to the stream provided. There is no way | ||
to unpipe. When data is emitted, it is immediately written to any and | ||
all pipe destinations. | ||
* `on(ev, fn)`, `emit(ev, fn)` - Minipass streams are EventEmitters. | ||
Some events are given special treatment, however. (See below under | ||
"events".) | ||
* `on(ev, fn)`, `emit(ev, fn)` - Minipass streams are EventEmitters. Some | ||
events are given special treatment, however. (See below under "events".) | ||
* `promise()` - Returns a Promise that resolves when the stream emits | ||
`end`, or rejects if the stream emits `error`. | ||
* `collect()` - Return a Promise that resolves on `end` with an array | ||
containing each chunk of data that was emitted, or rejects if the | ||
stream emits `error`. Note that this consumes the stream data. | ||
* `concat()` - Same as `collect()`, but concatenates the data into a | ||
single Buffer object. Will reject the returned promise if the stream is | ||
in objectMode, or if it goes into objectMode by the end of the data. | ||
containing each chunk of data that was emitted, or rejects if the stream | ||
emits `error`. Note that this consumes the stream data. | ||
* `concat()` - Same as `collect()`, but concatenates the data into a single | ||
Buffer object. Will reject the returned promise if the stream is in | ||
objectMode, or if it goes into objectMode by the end of the data. | ||
* `read(n)` - Consume `n` bytes of data out of the buffer. If `n` is not | ||
@@ -429,4 +430,4 @@ provided, then consume all of it. If `n` bytes are not available, then | ||
You can iterate over streams synchronously or asynchronously in | ||
platforms that support it. | ||
You can iterate over streams synchronously or asynchronously in platforms | ||
that support it. | ||
@@ -439,5 +440,4 @@ Synchronous iteration will end when the currently available data is | ||
To consume chunks in this way exactly as they have been written, with | ||
no flattening, create the stream with the `{ objectMode: true }` | ||
option. | ||
To consume chunks in this way exactly as they have been written, with no | ||
flattening, create the stream with the `{ objectMode: true }` option. | ||
@@ -444,0 +444,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36495
460