{"id":13447000,"url":"https://github.com/juliangruber/binary-extract","last_synced_at":"2025-04-14T12:51:11.396Z","repository":{"id":15100710,"uuid":"17827449","full_name":"juliangruber/binary-extract","owner":"juliangruber","description":"Extract a value from a buffer of json without parsing the whole thing","archived":false,"fork":false,"pushed_at":"2018-02-10T07:44:07.000Z","size":24,"stargazers_count":153,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-21T12:11:00.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliangruber.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-17T12:39:00.000Z","updated_at":"2023-10-08T19:00:29.000Z","dependencies_parsed_at":"2022-09-08T15:11:34.697Z","dependency_job_id":null,"html_url":"https://github.com/juliangruber/binary-extract","commit_stats":null,"previous_names":["segmentio/binary-extract"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fbinary-extract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fbinary-extract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fbinary-extract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fbinary-extract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliangruber","download_url":"https://codeload.github.com/juliangruber/binary-extract/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248884895,"owners_count":21177527,"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":[],"created_at":"2024-07-31T05:01:05.460Z","updated_at":"2025-04-14T12:51:11.336Z","avatar_url":"https://github.com/juliangruber.png","language":"JavaScript","readme":"\n# binary-extract\n\n  Extract one or more values from a buffer of json without parsing the whole thing.\n\n  [![build status](https://secure.travis-ci.org/juliangruber/binary-extract.png)](http://travis-ci.org/juliangruber/binary-extract)\n\n## Example\n\n```js\nvar extract = require('binary-extract');\n\nvar buf = new Buffer(JSON.stringify({\n  foo: 'bar',\n  bar: 'baz',\n  nested: {\n    bar: 'nope'  \n  } \n}));\n\nvar value = extract(buf, 'bar');\n// =\u003e 'baz'\n\nvar values = extract(buf, ['foo', 'nested'])\n// =\u003e [\"bar\", {\"bar\":\"nope\"}]\n```\n\n## Perf\n\n  With the object from `bench.js`, `extract()` is ~2-4x faster than\n  `JSON.parse(buf.toString())`. It is also way more memory efficient as the\n  blob stays out of the V8 heap.\n\n  The big perf gain comes mainly from not parsing everything and not\n  converting the buffer to a string.\n\n## Installation\n\n```bash\n$ npm install binary-extract\n```\n\n## API\n\n### extract(buf, keys)\n\n  Extract the value of `keys` in the json `buf`.\n\n  The value can be any valid JSON structure.\n\n  If `keys` is a __String__, returns a value. If `keys` is an __Array__ of\n  keys, returns an array of values.\n\n## Sponsors\n\nThis module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!\n\nDo you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!\n\n## License\n\n  MIT\n\n","funding_links":["https://www.patreon.com/juliangruber"],"categories":["Packages","JavaScript","包","目录","Parsing","Number","file format (文件格式)"],"sub_categories":["Parsing","解析","解析工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Fbinary-extract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliangruber%2Fbinary-extract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Fbinary-extract/lists"}