1.0.6 • Published 6 years ago

json-input-stream v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

npm version npm downloads dependencies Status license:mit

json-input-stream

json-input-stream transforms the incoming data into a JSON object.

I made this because I always use JSON objects as response from my API, and using fs.createReadStream with a pipeline to the response would send the inside of the file, without the pretty looking JSON response. This way I still have the JSON responses, and don't run out of memory if using fs.readFileSync on huge files and creating the JSON response with the returned data from fs.readFileSync.

Documentation

Transform(data)

  • data - The object you want the incoming data to be transformed into. This object must contain the JsonInputStream.OUTPUT_LOCATION variable, this is where the input data is going to be located.

Example:

let JsonInputStream = require('json-input-stream');
let fs = require('fs');

fs.createReadStream('./content-file.txt', 'utf8')
    .pipe(JsonInputStream({
        success: true,
        result: {
            content: JsonInputStream.OUTPUT_LOCATION
        }
    }))
    .pipe(fs.createWriteStream('./json-file.json'));
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago