New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

json-input-stream

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-input-stream

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

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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'));

FAQs

Package last updated on 22 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts