{"_id":"iterable-ndjson","_rev":"4573545","name":"iterable-ndjson","description":"ndjson to async iterator","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"alanshaw","email":""}],"time":{"modified":"2026-04-10T15:35:12.000Z","created":"2019-02-12T12:57:50.423Z","1.1.0":"2019-03-27T21:56:12.675Z","1.0.1":"2019-03-07T10:29:05.510Z","1.0.0":"2019-02-12T12:57:50.423Z"},"users":{},"author":{"name":"Alan Shaw"},"repository":{"type":"git","url":"git+https://github.com/alanshaw/iterable-ndjson.git"},"versions":{"1.1.0":{"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":{"shasum":"36f7e8a5bb04fd087d384f29e44fc4280fc014fc","size":3200,"noattachment":false,"key":"/iterable-ndjson/-/iterable-ndjson-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/iterable-ndjson/download/iterable-ndjson-1.1.0.tgz"},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"alanshaw","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterable-ndjson_1.1.0_1553723772538_0.8161287468356822"},"_hasShrinkwrap":false,"publish_time":1553723772675,"_cnpm_publish_time":1553723772675,"_cnpmcore_publish_time":"2021-12-16T18:33:55.427Z"},"1.0.1":{"name":"iterable-ndjson","version":"1.0.1","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":"828a995e415382278153b7584646f973be7f4d17","_id":"iterable-ndjson@1.0.1","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"shasum":"e5797b120cfc41df61d555f4d6a92bfc5e78f441","size":2951,"noattachment":false,"key":"/iterable-ndjson/-/iterable-ndjson-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/iterable-ndjson/download/iterable-ndjson-1.0.1.tgz"},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"alanshaw","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterable-ndjson_1.0.1_1551954545413_0.3223599279035978"},"_hasShrinkwrap":false,"publish_time":1551954545510,"_cnpm_publish_time":1551954545510,"_cnpmcore_publish_time":"2021-12-16T18:33:55.638Z"},"1.0.0":{"name":"iterable-ndjson","version":"1.0.0","description":"ndjson to async iterator","main":"index.js","scripts":{"test":"standard && nyc --reporter=lcov --reporter=text ava --verbose"},"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":{"ava":"^1.2.1","nyc":"^13.2.0","standard":"^12.0.1"},"dependencies":{"string_decoder":"^1.2.0"},"gitHead":"2a677775f33ba8a3d60cf5adddc7e38a404e2d53","_id":"iterable-ndjson@1.0.0","_npmVersion":"6.5.0","_nodeVersion":"11.9.0","_npmUser":{"name":"alanshaw","email":"alan138@gmail.com"},"dist":{"shasum":"0946ae5c506074abbe85d37ee1639c1ec46689c2","size":1787,"noattachment":false,"key":"/iterable-ndjson/-/iterable-ndjson-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/iterable-ndjson/download/iterable-ndjson-1.0.0.tgz"},"maintainers":[{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"alanshaw","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterable-ndjson_1.0.0_1549976270276_0.9716075569007288"},"_hasShrinkwrap":false,"publish_time":1549976270423,"_cnpm_publish_time":1549976270423,"_cnpmcore_publish_time":"2021-12-16T18:33:55.825Z"}},"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","_attachments":{},"homepage":"https://github.com/alanshaw/iterable-ndjson#readme","bugs":{"url":"https://github.com/alanshaw/iterable-ndjson/issues"},"license":"MIT"}