always-stream
Create stream from any value - function, array, string, buffer, promise, number, object and etc. Always returns a function that returns Transform Stream, using through2.
Note: This is just a thin wrapper around callback2stream and value2stream.
Install
npm i always-stream --save
Usage
For more use-cases see the tests
const alwaysStream =
alwaysStream
Create a stream from any value.
Params
val
{Mixed}: Any type of value.[opts]
{Object|Function=}: Directly passed to value2stream, callback2stream and through2.[Promize]
{Function}: Promise constructor to be used when no support for native Promise. Can be 2nd argument.returns
{Function}: That when executed, returnsTransformStream
, using through2
Example
var fs = var toStream = var numberStream = var stringStream = var readFile = // or sync functionsvar statFile = // also works for native functions// like JSON.parse and JSON.stringify// by respect optional argumentsvar stringifyStream =
Related
- callback2stream: Transform sync, async or generator function to Stream. Correctly handle errors. homepage
- letta: Let's move to promises! Drop-in replacement for
co@4
(passing 100% tests) homepage - limon: The pluggable JavaScript lexer. Limon = Lemon. | homepage
- postjson: Transforming JSON with plugins. | homepage
- promise2stream: Transform ES2015 Promise to Stream - specifically, Transform Stream… more | homepage
- relike: Simple promisify a callback-style function with sane defaults. Support promisify-ing sync functions. | homepage
- value2stream: Transform any value to stream. Create stream from any value - string,… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.