Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/fast-json-data
Fast JSON data disk read/write.
https://github.com/stagas/fast-json-data
Last synced: 14 days ago
JSON representation
Fast JSON data disk read/write.
- Host: GitHub
- URL: https://github.com/stagas/fast-json-data
- Owner: stagas
- License: mit
- Created: 2022-08-05T01:48:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-09T04:47:46.000Z (over 2 years ago)
- Last Synced: 2024-09-15T16:49:36.542Z (2 months ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fast-json-dataFast JSON data disk read/write.
npm i fast-json-data
pnpm add fast-json-data
yarn add fast-json-data
Efficiently read and write well-formed JSON data to the disk. About x1.5-2 times as fast as JSON.parse/stringify.
```ts
import { Literal, parse, stringify } from 'fast-json-data'const schema = [[Literal, [
'_id',
'_rev',
'name',
'homepage',
['versions', ['*', [
'name',
'gitHead',
['os', [Literal]],
['cpu', [Literal]],
['engines', ['*']],
['dist', [
'shasum',
'tarball',
'unpackedSize',
]],
['dependencies', [
'*',
]],
]]],['time', ['*']],
]]]...
// packumentCache is a Map
await fsp.writeFile(
options.packumentCachePath,
stringify(schema, [...packumentCache]),
'utf-8'
)...
json = parse(schema, await fsp.readFile(options.packumentCachePath, 'utf-8'))
```## API
#
Literal
=...
src/fast-json-data.ts#L1
typeof Literal
parse
(schema, input) src/fast-json-data.ts#L62 # parseLines
(schema, input) src/fast-json-data.ts#L66 # schema
any
input
string [] & {
# index
src/fast-json-data.ts#L66
number
parseLines(schema, input) =>
- any
stringify
(schema, input) src/fast-json-data.ts#L3
## Contributing
[Fork](https://github.com/stagas/fast-json-data/fork) or [edit](https://github.dev/stagas/fast-json-data) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)