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

parse-concat-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-concat-stream

concat-stream + JSON.parse + callback interface and custom parsers

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

parse-concat-stream Build Status Dependency Status DevDependency Status

npm

The simplest possible combination of concat-stream and native JSON.parse. It provides callback interface just like concat-stream does and accepts custom parser functions.

Example

> stread('{ "foo": 1, "bar": [2, 3] }')
    .pipe(parseConcat(function (err, data) {
      if (err) throw err;
      console.log(JSON.stringify(data, null, 1));
    }));
{
 "foo": 1,
 "bar": [
  2,
  3
 ]
}

Custom parser:

> var caps = function (string) {
    return (string.match(/[A-Z]/g) || []).join('').toLowerCase();
  };
> stread('   {\nMEdiS]]\n} SorAs    \tGEt')
    .pipe(parseConcat({ parse: caps }, function (err, data) {
      if (err) throw err;
      console.log(JSON.stringify(data));
    }));
"message"

API

parseConcat([opts], cb(err, data))

Return a writable stream, run cb once it closes.

data is JSON.parsed by default, unless custom opts.parse is provided.

null is a shorthand for the identity function, so that

parseConcat({ parse: null }, cb);

is equivalent to

require('concat-stream')({ encoding: 'string' }, cb.bind(null, null));
OptionTypeRequired?Default
parsefunction(string)NoJSON.parse

Install

npm install parse-concat-stream

License

MIT

Keywords

concat

FAQs

Package last updated on 20 Nov 2014

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