{"_id":"@amitic/fast-json","name":"@amitic/fast-json","dist-tags":{"latest":"2.1.2"},"versions":{"2.1.2":{"name":"@amitic/fast-json","description":"A lightning fast on the fly JSON parser","version":"2.1.2","author":{"name":"Alejandro Santiago Nieto"},"license":"MIT","devDependencies":{"chai":"^4.3.4","eslint":"^7.27.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.23.3","jsdoc":"^3.6.7","mocha":"^8.4.0","nyc":"^15.1.0"},"main":"index.js","scripts":{"test":"mocha test/*.js","test:cover":"nyc --reporter=lcov --reporter=text-summary npm test","lint":"eslint index.js lib/*.js test/*.js example/*.js benchmark/*.js","lint:fix":"eslint index.js lib/*.js test/*.js example/*.js benchmark/*.js --fix","check":"npm test && npm run lint && npm outdated","doc":"jsdoc ./lib/ ./package.json ./README.md -d ./doc","benchmark":"node benchmark/index.js"},"repository":{"type":"git","url":"git+https://github.com/alemures/fast-json.git"},"gitHead":"0375630af61d1c4c87c78bdd12546e14eead0090","bugs":{"url":"https://github.com/alemures/fast-json/issues"},"homepage":"https://github.com/alemures/fast-json#readme","_id":"@amitic/fast-json@2.1.2","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-La9Ok+xjVltCpZ7XDVVOA1dP9F6cey42fidK6a1GUlKx0G1/2vGahvZaz2SStWs+hYgShLc0qbr51UOvGD2QKQ==","shasum":"fbff8dc9c216ff3a353271875bf2631188b31568","tarball":"https://registry.npmjs.org/@amitic/fast-json/-/fast-json-2.1.2.tgz","fileCount":6,"unpackedSize":18575,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDSyu+m48C6tI0ivcCePhc4KOHZpzdLPIVkMr+NsPynOAIgfwVbdbT6KICRTdA7C3qti9aS9daWja5pFIVgcIyiAj8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjRBxSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrx1A//ezYWmwgSS1hEu/7GSc7sogbELCpNa1ufj1/FcHAkI/SlDB1I\r\n6AljsSUJV4ESaCms5gopAmG7jACrCKGyCyHPgDE2qPDIFYjDfCgW5ionywa1\r\ng6q6jOStH+oGh+OifsTyQxIDyDw8p++tN4LaMoPwFEEp10I6OQOENuLyuwFI\r\nl16g1P7121hbz+h1Cf31Ccw5YleTLRDRgm60Yy2ybPO8MiqQUID1Iy8Hx9na\r\nLEomQRrkoZi3Z6Z7uJJ8S9pJL7CKBAawarXf369353lDLuophbmOhwpvTUzz\r\ntVv+axw1Ysj0KG7xh0emNr48guTW77C6VGHy1BvNIfUQl5kYIXNStU/8fUIv\r\nwaiDhEp7TdnTq4K1R/e20B3Dv1XpRo11poxLa+130JnFe4X17EtrT0FgoSyv\r\nRSK3rTduS6GrBRa5dWyZUNfw8FRbx7NlflxJj13dynPk/3PPO/5Z7f25b/zB\r\nVadT26cRQ+AihVivRRnBTUDvTt1s/MacLhXboD5G7qb5fWN92ufQbGOs0p/g\r\nh1XJxSA6UsjXAWaFLR2f84n58SkPG/hKUMoWf/mQ5wbUaU7j5X2RYtidGh2j\r\nafjTD3zr2kSiVMVvGKU7nP8aPXByoOobsq6GtAMphhO/KC+5V4V8kmD8R9fg\r\nQoYm35Oekii6BKl94YuouZk7iWhFJ9dlv0g=\r\n=LQ6Z\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"amitic","email":"amitic@gmail.com"},"directories":{},"maintainers":[{"name":"amitic","email":"amitic@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fast-json_2.1.2_1665408081876_0.821539511758435"},"_hasShrinkwrap":false}},"time":{"created":"2022-10-10T13:21:21.822Z","2.1.2":"2022-10-10T13:21:22.105Z","modified":"2022-10-10T13:21:22.262Z"},"maintainers":[{"name":"amitic","email":"amitic@gmail.com"}],"description":"A lightning fast on the fly JSON parser","homepage":"https://github.com/alemures/fast-json#readme","repository":{"type":"git","url":"git+https://github.com/alemures/fast-json.git"},"author":{"name":"Alejandro Santiago Nieto"},"bugs":{"url":"https://github.com/alemures/fast-json/issues"},"license":"MIT","readme":"fast-json\n===\nA lightning fast on the fly **JSON parser** able to return JSON values and structures from plain JSON as `String` or `Buffer`. It's much faster than JSON.parse() and doesn't require any extra memory allocation for the data processed.\n\n## Install\n```\nnpm install fast-json\n```\n\n## Usage\n```javascript\nconst { FastJson } = require('fast-json');\n\nconst data = JSON.stringify({\n  ireland: {\n    people: [{ name: 'Alex' }, { name: 'John' }, { name: 'Cian' }],\n  },\n  spain: {\n    people: [{ name: 'Antonio' }, { name: 'Juan' }, { name: 'Pedro' }],\n  },\n});\n\nconst fastJson = new FastJson();\n\n// Path is a string representing a javascript object path\nfastJson.on('ireland.people', (value) => {\n  console.log('ireland.people ->', value);\n});\n\n// Paths can be also an array of keys\nfastJson.on(['spain', 'people', '1', 'name'], (value) => {\n  console.log(['spain', 'people', '1', 'name'], '->', value);\n});\n\n// Wildcards can be used to match all items in object or array\nfastJson.on('spain.people[*].name', (value) => {\n  console.log('spain.people[*].name ->', value);\n});\n\nfastJson.on('*.people[*].name', (value) => {\n  console.log('*.people[*].name ->', value);\n});\n\nfastJson.write(data);\n// The JSON can be string or Buffer\n// fastJson.write(Buffer.from(data))\n```\n\n```javascript\nfastJson.on('ireland.people[1].name', (value) => {\n  console.log('ireland.people[1].name ->', value);\n  // Once we have all we need, we can skip the rest of the JSON to improve performance.\n  fastJson.skip();\n});\n```\n\n```javascript\n// Path separator defines the keys separator on the listeners\nconst fastJson = new FastJson({ pathSeparator: '/' });\n\n// In this case it allows keys having dots by using a different separator\nfastJson.on('unknown.country/people/0/name', (value) => {\n  console.log('unknown.country/people/0/name ->', value);\n});\n```\n\n## Performance\nJSON file *citylots.json* of **189MB** from https://github.com/zemirco/sf-city-lots-json.\n\n* **fast-json: 0.56s / 198MB RAM**\n* JSON.parse: 1.8s / 640MB RAM\n* jsonparse: 15.0s / 1,100MB RAM (Only reading, it wasn't able to return a value)\n\n## TODO\n* [**Feature**] Allow chunked JSON.\n* [**Feature**] Match more glob patters.\n* [**Feature**] Add more flexibility to event listeners (on, once, off, etc).\n* [**Documentation**] Create branch gh-pages using *jsdoc*.\n* [**Documentation**] More real life testing and examples.\n","readmeFilename":"README.md"}