{"name":"iterable-ndjson","version":"1.1.0","description":"ndjson to async iterator","main":"index.js","browser":"browser.js","scripts":{"test":"npm run test:node && npm run test:browser","test:node":"tape test.js","test:browser":"webpack --config webpack.test.config.js && cat output/test.js | tape-puppet","coverage":"standard && nyc --reporter=lcov --reporter=text tape test.js"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/iterable-ndjson.git"},"keywords":["ndjson","json","async","iterator","iterable"],"author":{"name":"Alan Shaw"},"license":"MIT","bugs":{"url":"https://github.com/alanshaw/iterable-ndjson/issues"},"homepage":"https://github.com/alanshaw/iterable-ndjson#readme","devDependencies":{"nyc":"^13.2.0","standard":"^12.0.1","tape":"^4.10.1","tape-puppet":"^0.1.7","webpack":"^4.29.6","webpack-cli":"^3.2.3"},"dependencies":{"string_decoder":"^1.2.0"},"gitHead":"8f80a8fd70c6d4df87c4817c63dfafa97ecd3dec","_id":"iterable-ndjson@1.1.0","_nodeVersion":"11.11.0","_npmVersion":"6.7.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"integrity":"sha512-OOp1Lb0o3k5MkXHx1YaIY5Z0ELosZfTnBaas9f8opJVcZGBIONA2zY/6CYE+LKkqrSDooIneZbrBGgOZnHPkrg==","shasum":"36f7e8a5bb04fd087d384f29e44fc4280fc014fc","tarball":"http://registry-npm.ywwl.com/iterable-ndjson/download/iterable-ndjson-1.1.0.tgz","fileCount":11,"unpackedSize":9629,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcm/F9CRA9TVsSAnZWagAAM9YQAJEPtiSBncRNHxNLRszu\nOm31G2s9a13DkXMJIc+nNCzy9pkBT+vvnLnGacJxbPQDOUDvKJveZqkd7LOe\n0V1DXME9vaH/BQGAnbj8Fp/Ue3Q7VaJJ5SWj4sEDo5WV0H5HDLZYMaW5LKGE\noWF2/MFHchAa0evselB8tHBAyebeXnzFDTiZKs67//L/PvMgT39DripyKh9Z\nM5wVrXcnUGYheDNzG5rOufpglHhY0ui96jzAAKOCR1WBkmnZWuBu0QBQjR7C\nA/zLt1tKtmi4xRLA5ZC8q95MU2cR83582RzpwCvM2aClXyjh8O20VMGho5PU\nLQqObo+sLVHOBp3/t4mTekeZ7up4RE3oKbkmAG+nBTLjg70lkP4PoIp66t/Y\nr6R/zgjFfh+n3ZXTJMwye5pdJ+M7nzrnH3g91eKGcvv1i62aFAJstVAHjo7V\nwyz/6seulz347tLYvFQT9n1bJ+ODoss0KNq9kUWuJ/5cB9d/oHy+VmJni0Pt\nca1QfOHrjsZswVxi5M/I6sqdgV++m67QSjo/a10gbbLrw/6s5znOiPED5bbk\n5uzBD8zYfB2sTwMSvtzAiSUSA6KizgfvC99s0y8SJfkF+Q0uCC0oVjtHvntF\nlADHcQ+rCQSMmT15f35ULsAvcfgq95FrcKOH+oAqmRJTMdATwTtmOhGKedK/\nKm/N\r\n=ClSq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH5k1IQnVLjFHtO3K94gK3iea6fnplP0KoBQn+DWQ1ILAiEA80eZCWirnh2a7CSgclxWoXJv9Zl2E42SRQDamWL+EBc="}],"size":3200,"noattachment":false,"key":"/iterable-ndjson/-/iterable-ndjson-1.1.0.tgz"},"maintainers":[{"name":"alanshaw","email":"alan138@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterable-ndjson_1.1.0_1553723772538_0.8161287468356822"},"_hasShrinkwrap":false,"readme":"# iterable-ndjson\n\n[![Build Status](https://travis-ci.org/alanshaw/iterable-ndjson.svg?branch=master)](https://travis-ci.org/alanshaw/iterable-ndjson)\n[![dependencies Status](https://david-dm.org/alanshaw/iterable-ndjson/status.svg)](https://david-dm.org/alanshaw/iterable-ndjson)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n> Takes an (async) iterable that yields ndjson and returns an async iterable that yields JS objects\n\n## Install\n\n```sh\nnpm install iterable-ndjson\n```\n\n## Usage\n\n```js\nconst ndjson = require('iterable-ndjson')\nconst it = ndjson.parse(source) // where `source` is any iterable that yields ndjson\n\nfor await (const obj of it)\n  console.log(obj)\n```\n\n### Examples\n\nNode.js streams are async iterable:\n\n```js\nconst ndjson = require('iterable-ndjson')\nconst fs = require('fs')\nconst source = fs.createReadStream('/path/to/file.ndjson')\n\nfor await (const obj of ndjson.parse(source))\n  console.log(obj)\n```\n\nAsync iterable:\n\n```js\nconst ndjson = require('iterable-ndjson')\n\n// An ndjson async iterator\nconst source = (() => {\n  const array = ['{\"id\": 1}\\n', '{\"id\"', ': 2}', '\\n{\"id\": 3}\\n']\n  return {\n    [Symbol.asyncIterator] () {\n      return this\n    },\n    async next () {\n      await new Promise(resolve => setTimeout(resolve))\n      return array.length\n        ? { done: false, value: array.shift() }\n        : { done: true }\n    }\n  }\n})()\n\nasync function main () {\n  for await (const obj of ndjson.parse(source))\n    console.log(obj)\n    // Logs out:\n    // { id: 1 }\n    // { id: 2 }\n    // { id: 3 }\n}\n\nmain()\n```\n\nAsync iterable generator:\n\n```js\nconst ndjson = require('iterable-ndjson')\n\n// An ndjson async iterator\nconst source = (async function * () {\n  const array = ['{\"id\": 1}\\n', '{\"id\"', ': 2}', '\\n{\"id\": 3}\\n']\n  for (let i = 0; i < array.length; i++) {\n    yield new Promise(resolve => setTimeout(() => resolve(array[i])))\n  }\n})()\n\nasync function main () {\n  for await (const obj of ndjson.parse(source))\n    console.log(obj)\n    // Logs out:\n    // { id: 1 }\n    // { id: 2 }\n    // { id: 3 }\n}\n\nmain()\n```\n\nRegular iterable (like an array):\n\n```js\nconst ndjson = require('iterable-ndjson')\nconst source = ['{\"id\": 1}\\n', '{\"id\"', ': 2}', '\\n{\"id\": 3}\\n']\n\nasync function main () {\n  for await (const obj of ndjson.parse(source))\n    console.log(obj)\n    // Logs out:\n    // { id: 1 }\n    // { id: 2 }\n    // { id: 3 }\n}\n\nmain()\n```\n\nStringify JS objects to NDJSON:\n\n```js\nconst ndjson = require('iterable-ndjson')\nconst source = [{ id: 1 }, { id: 2 }, { id: 3 }]\n\nasync function main () {\n  for await (const obj of ndjson.stringify(source))\n    console.log(obj)\n    // Logs out:\n    // '{\"id\":1}\\n'\n    // '{\"id\":2}\\n'\n    // '{\"id\":3}\\n'\n}\n\nmain()\n```\n\n## Contribute\n\nFeel free to dive in! [Open an issue](https://github.com/alanshaw/iterable-ndjson/issues/new) or submit PRs.\n\n## License\n\n[MIT](LICENSE) © Alan Shaw\n","publish_time":1553723772675,"_cnpm_publish_time":1553723772675,"dist-tags":{"latest":"1.1.0"}}