2.0.0 • Published 5 years ago

j-streamify v2.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

J-Streamify

Stream javascript objects as a json string. Accepts promises and streams.

(note): versions <= 1.0.5 do not support objectMode streams.

(important!): Circular objects are not supported and will cause memory leaks.

version >= 2.0.0 require node 12 or above

Installing

npm install j-streamify --save

Examples

use case: Sending file on disk to a legacy api as json:

const request = require('request');
const jStream = require('j-streamify');

const payload = jStream({
  filename: 'image.png',
  data: fs.createReadStream('path/to/png.png'),
  meta: metaData.find({name: 'image.png'}).then(x => x.data),
});

payload.pipe(request({ uri: '/destination', method: 'POST', json: true });

Converting a stream of objects to a stream of an equivalent JSON string:

const writeStream = fs.createWriteStream('myCollection.json');
const objectStream = mongoCollection.find({});

jStream(objectStream).pipe(writeStream);

Tests

From the j-streamify root directory run:

npm install
npm run test

This will generate a coverage report inside the root directory in a new directory called coverage

License

This project is licensed under the MIT License - see the LICENSE.md file for details

2.0.0

5 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago