Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takase1121/watson.js
Library to deal with WATSON
https://github.com/takase1121/watson.js
Last synced: 4 days ago
JSON representation
Library to deal with WATSON
- Host: GitHub
- URL: https://github.com/takase1121/watson.js
- Owner: takase1121
- License: mit
- Created: 2021-01-01T05:57:37.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T00:09:47.000Z (about 2 years ago)
- Last Synced: 2024-11-26T12:16:33.961Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.09 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WATSON.js
A encoder and decoder for [WATSON](https://github.com/genkami/watson).
The API is similiar to [JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON).
Supports Node.js > 10 or browser with similiar level of JS support.
### Examples:
```js
const WATSON = require('watson.js')
const data = { hello: 'world' }
const s = WATSON.stringify(data)const prettified = WATSON.stringify(data, { prettify: true })
const SFirst = WATSON.stringify(data, { mode: 'S' })WATSON.parse(s)
WATSON.parse(SFirst, { mode: 'S' })// unsafe parsing
// this mode tries to replace possible string operations with float instead of int
// this is because WATSON's int maps to BigInt, which is slow on most platforms
// this mode detects sadd/snew, inew and replace them with float operations
WATSON.parse(s, { unsafe: true })
```#### Some notes
The implementation is now faster after most lazy evaluation code is replaced with eager evaluations.
Any improvements are still welcome.#### Benchmark because why not
```
stringify x 55,492 ops/sec ±2.63% (77 runs sampled)
parse x 51,515 ops/sec ±2.52% (80 runs sampled)
parse unsafe x 54,400 ops/sec ±2.51% (74 runs sampled)
```