{"id":22322405,"url":"https://github.com/busterc/fs-ndjson","last_synced_at":"2025-07-29T15:30:59.364Z","repository":{"id":57242303,"uuid":"121443336","full_name":"busterc/fs-ndjson","owner":"busterc","description":":information_source: read and write NDJSON files (Newline Delimited JSON)","archived":false,"fork":false,"pushed_at":"2019-10-02T14:27:34.000Z","size":47,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T20:49:46.868Z","etag":null,"topics":["json","jsonld","jsonlines","ldjson","ndjson"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/busterc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-13T22:19:01.000Z","updated_at":"2023-09-08T17:36:38.000Z","dependencies_parsed_at":"2022-09-07T23:13:29.413Z","dependency_job_id":null,"html_url":"https://github.com/busterc/fs-ndjson","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Ffs-ndjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Ffs-ndjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Ffs-ndjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Ffs-ndjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/busterc","download_url":"https://codeload.github.com/busterc/fs-ndjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227877503,"owners_count":17833473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","jsonld","jsonlines","ldjson","ndjson"],"created_at":"2024-12-04T01:07:15.395Z","updated_at":"2024-12-04T01:07:15.826Z","avatar_url":"https://github.com/busterc.png","language":"JavaScript","readme":"# fs-ndjson [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\n\u003e read and write NDJSON files (Newline Delimited JSON)\n\n## FYI\n\nWhile NDJSON is often used for [efficient streaming of JSON](https://www.npmjs.com/package/ndjson), it is also a good format for persisting and retreiving object data collections to and from disk. For example, [NeDB](https://github.com/louischatriot/nedb) uses the format.\n\nSee Also:\n\n* http://ndjson.org/\n* https://en.wikipedia.org/wiki/JSON_streaming#Line-delimited_JSON\n\n## API\n\nThe following `fs-ndjson` methods mirror the `fs` core module method APIs, however, the methods have been [universalified](https://github.com/RyanZim/universalify) so that you can use promises or callbacks for async.\n\n* readFile\n* readFileSync\n* writeFile\n* writeFileSync\n\n**BONUS:** `writeFile` and `writeFileSync` will create the parent directory, if it does not already exist.\n\n## Installation\n\n```sh\n$ npm install --save fs-ndjson\n```\n\n## Usage\n\nGiven `/Users/tyler/project-mayhem/enemies.db` contains\n\n```\n  {\"name\":\"Equifax\",\"location\":\"Atlanta, GA\"}\n  {\"name\":\"Visa\",\"location\":\"Foster City, CA\"}\n```\n\n```js\nconst fsNdjson = require('fs-ndjson');\n\n// can return a promise\nfsNdjson.readFile('/Users/tyler/project-mayhem/enemies.db').then(targets =\u003e {\n  console.log(targets);\n  // [\n  //   {\n  //     name: \"Equifax\",\n  //     location: \"Atlanta, GA\"\n  //   },\n  //   {\n  //     name: \"Visa\",\n  //     location: \"Foster City, CA\"\n  //   }\n  // ]\n});\n\n// can use a callback\nfsNdjson.readFile('/Users/tyler/project-mayhem/enemies.db', (err, enemies) =\u003e {\n  if (err) throw err;\n  console.log(enemies.length);\n  // =\u003e 2\n});\n\n// can be used synchronously\nlet enemies = fsNdjson.readFileSync('/Users/tyler/project-mayhem/enemies.db');\n\n// ******** BUT WAIT, THERE'S MORE! ******** //\n// Not only does it read, but it writes too! //\n\n// fsNdjson.writeFile     // use callback or promise\n// fsNdjson.writeFileSync // does what you think it does\n```\n\n## License\n\nISC © [Buster Collings](https://about.me/buster)\n\n[npm-image]: https://badge.fury.io/js/fs-ndjson.svg\n[npm-url]: https://npmjs.org/package/fs-ndjson\n[travis-image]: https://travis-ci.org/busterc/fs-ndjson.svg?branch=master\n[travis-url]: https://travis-ci.org/busterc/fs-ndjson\n[daviddm-image]: https://david-dm.org/busterc/fs-ndjson.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/busterc/fs-ndjson\n[coveralls-image]: https://coveralls.io/repos/busterc/fs-ndjson/badge.svg\n[coveralls-url]: https://coveralls.io/r/busterc/fs-ndjson\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Ffs-ndjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbusterc%2Ffs-ndjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Ffs-ndjson/lists"}