{"name":"stream-json","version":"1.3.2","description":"stream-json is the micro-library of Node.js stream components for creating custom JSON processing pipelines with a minimal memory footprint. It can parse JSON files far exceeding available memory streaming individual primitives using a SAX-inspired API. I","homepage":"http://github.com/uhop/stream-json","bugs":{"url":"http://github.com/uhop/stream-json/issues"},"main":"index.js","directories":{"test":"tests"},"dependencies":{"stream-chain":"^2.2.1"},"devDependencies":{"heya-unit":"^0.3.0"},"scripts":{"test":"node tests/tests.js"},"github":"http://github.com/uhop/stream-json","repository":{"type":"git","url":"git://github.com/uhop/stream-json.git"},"keywords":["scanner","lexer","tokenizer","parser","django","stream","streaming","json"],"author":{"name":"Eugene Lazutkin","email":"eugene.lazutkin@gmail.com","url":"http://lazutkin.com/"},"license":"BSD-3-Clause","gitHead":"ab463181a40ea8de0ccc9917a077b00e5097a364","_id":"stream-json@1.3.2","_nodeVersion":"13.5.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-PMpEe2oMnqZChTTBxjkYi35z36awSWU/Ev9CRYGKQYxkDcmoC5D1/aklNB4L2y6qt/cSI4sLe2br4PMt4Ruqiw==","shasum":"c90a920c0fa9bdaef82002af3383f546d42f29b3","tarball":"http://registry-npm.ywwl.com/stream-json/download/stream-json-1.3.2.tgz","fileCount":48,"unpackedSize":210266,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeFUlcCRA9TVsSAnZWagAAO/4QAIrICOsIJeZ8tzP4KvWL\nrdc88hLWhoEgcHfPdRQKaMMSVeTLGITEXZFEcKj4nUsxb4yb59QHe7MQQpPp\nyhOL3szjgQkmahnSvgr0bg214JxrIwmk++9k8nts9QihBB51DfIrvByfmoWV\n+GCDih+dsqCFA4ckYEgUly1ZOdG2YkFxKrLATT7GiAt9oPM/XBpSyElyPnPy\nJJN4mpfC3kEDDbSqxDxtic8pciSJ5uu0g03iWWAkaEZTRkNY+gX1OXK0B9vF\nN51xOG9Kztl7fm8nbvGoy/KHlPaf1m9Ecb1c9XfblN0yKn6uTdsOSOwi3Poe\n09tImXhqO5C++urjok6+h8RMLmZBkHnvQvXlNCtGT9slyn9ev+/RiccJs5Kp\nJmvrt6wXMXyIWbnVPnWDnQEG+V2t5c/EdHVCOxUy3hR6Q7gp/SySaDBAEOHI\nr0nvAjjqtjc88uLIp/+kaRcxns5HLhcN+n6lMYIh/aBiA/0mT9LTvmJ7363V\nQzcL/7xSozG0ZC1ZAxRN6e/4hok1UIlx1EQUwF5ySUiPs92NT5WUGDBwkqwU\nHqeUyQvV7To5eyQLiJF370oQMWR1nhmNquQVJyBdsSsLdPP37MKEopWlTvrj\nUOwGAAi6n7H2ewMlbpj8H0nMFJCZ0Zma+fkvphkc8CyQJmI7Y0UtV+Ki09Lw\nKzPP\r\n=Pn0P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBY0+DknMwdutrPSjtl1xrJl7K4hIK3cKNrYswCs7+HAIgJ0nCrDTLrvw69EJHZQS7s/gWQEH0XOOeTWI/Sxj38Qs="}],"size":78767,"noattachment":false,"key":"/stream-json/-/stream-json-1.3.2.tgz"},"maintainers":[{"name":"elazutkin","email":"eugene@lazutkin.com"}],"_npmUser":{"name":"elazutkin","email":"eugene.lazutkin@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-json_1.3.2_1578453339541_0.47780342399002884"},"_hasShrinkwrap":false,"readme":"# stream-json [![NPM version][npm-image]][npm-url]\n\n[npm-image]:      https://img.shields.io/npm/v/stream-json.svg\n[npm-url]:        https://npmjs.org/package/stream-json\n\n`stream-json` is a micro-library of node.js stream components with minimal dependencies for creating custom data processors oriented on processing huge JSON files while requiring a minimal memory footprint. It can parse JSON files far exceeding available memory. Even individual primitive data items (keys, strings, and numbers) can be streamed piece-wise. Streaming SAX-inspired event-based API is included as well.\n\nAvailable components:\n\n* Streaming JSON [Parser](https://github.com/uhop/stream-json/wiki/Parser).\n  * It produces a SAX-like token stream.\n  * Optionally it can pack keys, strings, and numbers (controlled separately).\n  * The [main module](https://github.com/uhop/stream-json/wiki/Main-module) provides helpers to create a parser.\n* Filters to edit a token stream:\n  * [Pick](https://github.com/uhop/stream-json/wiki/Pick) selects desired objects.\n    * It can produces multiple top-level objects just like in [JSON Streaming](https://en.wikipedia.org/wiki/JSON_Streaming) protocol.\n    * Don't forget to use [StreamValues](https://github.com/uhop/stream-json/wiki/StreamValues) when picking several subobjects!\n  * [Replace](https://github.com/uhop/stream-json/wiki/Replace) substitutes objects with a replacement.\n  * [Ignore](https://github.com/uhop/stream-json/wiki/Ignore) removes objects.\n  * [Filter](https://github.com/uhop/stream-json/wiki/Filter) filters tokens maintaining stream's validity.\n* Streamers to produce a stream of JavaScript objects.\n  * [StreamValues](https://github.com/uhop/stream-json/wiki/StreamValues) can handle a stream of JSON objects.\n    * Useful to stream objects selected by `Pick`, or generated by other means.\n    * It supports [JSON Streaming](https://en.wikipedia.org/wiki/JSON_Streaming) protocol, where individual values are separated semantically (like in `\"{}[]\"`), or with white spaces (like in `\"true 1 null\"`).\n  * [StreamArray](https://github.com/uhop/stream-json/wiki/StreamArray) takes an array of objects and produces a stream of its components.\n    * It streams array components individually taking care of assembling them automatically.\n    * Created initially to deal with JSON files similar to [Django](https://www.djangoproject.com/)-produced database dumps.\n    * Only one top-level array per stream is valid!\n  * [StreamObject](https://github.com/uhop/stream-json/wiki/StreamObject) takes an object and produces a stream of its top-level properties.\n    * Only one top-level object per stream is valid!\n* Essentials:\n  * [Assembler](https://github.com/uhop/stream-json/wiki/Assembler) interprets a token stream creating JavaScript objects.\n  * [Disassembler](https://github.com/uhop/stream-json/wiki/Disassembler) produces a token stream from JavaScript objects.\n  * [Stringer](https://github.com/uhop/stream-json/wiki/Stringer) converts a token stream back into a JSON text stream.\n  * [Emitter](https://github.com/uhop/stream-json/wiki/Emitter) reads a token stream and emits each token as an event.\n    * It can greatly simplify data processing.\n* Utilities:\n  * [emit()](https://github.com/uhop/stream-json/wiki/emit()) makes any stream component to emit tokens as events.\n  * [withParser()](https://github.com/uhop/stream-json/wiki/withParser()) helps to create stream components with a parser.\n  * [Batch](https://github.com/uhop/stream-json/wiki/Batch) batches items into arrays to simplify their processing.\n  * [Verifier](https://github.com/uhop/stream-json/wiki/Verifier) reads a stream and verifies that it is a valid JSON.\n  * [Utf8Stream](https://github.com/uhop/stream-json/wiki/Utf8Stream) sanitizes multibyte `utf8` text input.\n* Special helpers:\n  * JSONL AKA [JSON Lines](http://jsonlines.org/) AKA [NDJSON](http://ndjson.org/):\n    * [jsonl/Parser](https://github.com/uhop/stream-json/wiki/jsonl-Parser) parses a JSONL file producing objects similar to `StreamValues`.\n      * Useful when we know that individual items can fit in memory.\n      * Generally it is faster than the equivalent combination of `Parser({jsonStreaming: true})` + `StreamValues`.\n    * [jsonl/Stringer](https://github.com/uhop/stream-json/wiki/jsonl-Stringer) produces a JSONL file from a stream of JavaScript objects.\n      * Generally it is faster than the equivalent combination of `Disassembler` + `Stringer`.\n\nAll components are meant to be building blocks to create flexible custom data processing pipelines. They can be extended and/or combined with custom code. They can be used together with [stream-chain](https://www.npmjs.com/package/stream-chain) to simplify data processing.\n\nThis toolkit is distributed under New BSD license.\n\n## Introduction\n\n```js\nconst {chain}  = require('stream-chain');\n\nconst {parser} = require('stream-json');\nconst {pick}   = require('stream-json/filters/Pick');\nconst {ignore} = require('stream-json/filters/Ignore');\nconst {streamValues} = require('stream-json/streamers/StreamValues');\n\nconst fs   = require('fs');\nconst zlib = require('zlib');\n\nconst pipeline = chain([\n  fs.createReadStream('sample.json.gz'),\n  zlib.createGunzip(),\n  parser(),\n  pick({filter: 'data'}),\n  ignore({filter: /\\b_meta\\b/i}),\n  streamValues(),\n  data => {\n    const value = data.value;\n    // keep data only for the accounting department\n    return value && value.department === 'accounting' ? data : null;\n  }\n]);\n\nlet counter = 0;\npipeline.on('data', () => ++counter);\npipeline.on('end', () =>\n  console.log(`The accounting department has ${counter} employees.`));\n```\n\nSee the full documentation in [Wiki](https://github.com/uhop/stream-json/wiki).\n\nCompanion projects:\n\n* [stream-csv-as-json](https://www.npmjs.com/package/stream-csv-as-json) streams huge CSV files in a format compatible with `stream-json`:\n  rows as arrays of string values. If a header row is used, it can stream rows as objects with named fields.\n\n## Installation\n\n```bash\nnpm install --save stream-json\n# or: yarn add stream-json\n```\n\n## Use\n\nThe whole library is organized as a set of small components, which can be combined to produce the most effective pipeline. All components are based on node.js\n[streams](http://nodejs.org/api/stream.html), and [events](http://nodejs.org/api/events.html). They implement all required standard APIs. It is easy to add your\nown components to solve your unique tasks.\n\nThe code of all components is compact and simple. Please take a look at their source code to see how things are implemented, so you can produce your own components\nin no time.\n\nObviously, if a bug is found, or a way to simplify existing components, or new generic components are created, which can be reused in a variety of projects,\ndon't hesitate to open a ticket, and/or create a pull request.\n\n## Release History\n\n- 1.8.0 *added an option to indicate/ignore JSONL errors. Thx, [AK](https://github.com/ak--47).*\n- 1.7.5 *fixed a stringer bug with ASCII control symbols. Thx, [Kraicheck](https://github.com/Kraicheck).*\n- 1.7.4 *updated dependency (`stream-chain`), bugfix: inconsistent object/array braces. Thx [Xiao Li](https://github.com/xli1000).*\n- 1.7.3 *added an assembler option to treat numbers as strings.*\n- 1.7.2 *added an error check for JSONL parsing. Thx [Marc-Andre Boily](https://github.com/maboily).*\n- 1.7.1 *minor bugfix and improved error reporting.*\n- 1.7.0 *added `utils/Utf8Stream` to sanitize `utf8` input, all parsers support it automatically. Thx [john30](https://github.com/john30) for the suggestion.*\n- 1.6.1 *the technical release, no need to upgrade.*\n- 1.6.0 *added `jsonl/Parser` and `jsonl/Stringer`.*\n\nThe rest can be consulted in the project's wiki [Release history](https://github.com/uhop/stream-json/wiki/Release-history).\n","publish_time":1578453339749,"_cnpm_publish_time":1578453339749,"dist-tags":{"latest":"3.9.0"}}