p-read-next-stream-chunk
v0.1.3
Published
Extended next-chunk.
Downloads
1,336
Readme
p-read-next-stream-chunk
Extended next-chunk.
If you just want an alias module for directly importing
next-chunk
's nextChunk
function, without the extra features:
import pReadNextStreamChunk from 'p-read-next-stream-chunk/alias'
API
This module exports one function:
pReadNextStreamChunk(someReadableStream[, opts])
Tries to read one next chunk from someReadableStream
.
Returns a promise for that next chunk.
Should return null
at end of stream as per
the objectMode spec.
opts
is an optional options object.
If it is set to a truthy value (e.g. an object),
pReadNextStreamChunk
switches to factory mode,
returnung a function preset
that remembers the someReadableStream
.
preset
will ignore any arguments and return promises for stream chunks.
opts
supports these keys:
undef
: Translateundefined
chunks to this value. Default:undefined
ignoreEmptyStr
: If set to a truthy value and the chunk is an empty string, ignore it.
Known issues
- Needs more/better tests and docs.
- No support for read length limits and cancellation. If you want those, have a look at @kevinoid's promised-read.
License
ISC