https://github.com/smallhelm/level-json-coerce-null
db.put(key, undefined....) will give you problems. This codec fixes it.
https://github.com/smallhelm/level-json-coerce-null
Last synced: 12 months ago
JSON representation
db.put(key, undefined....) will give you problems. This codec fixes it.
- Host: GitHub
- URL: https://github.com/smallhelm/level-json-coerce-null
- Owner: smallhelm
- License: mit
- Archived: true
- Created: 2016-09-01T20:47:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-01T21:49:43.000Z (over 9 years ago)
- Last Synced: 2025-06-06T15:02:25.401Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# level-json-coerce-null
[](https://travis-ci.org/smallhelm/level-json-coerce-null)
db.put(key, undefined....) will give you problems. This codec fixes it.
It simply coerces undefined to null so it will encode properly. Note that when it decodes it will be null instead of undefined.
To use it, simply change
```js
var db = level(... {
valueEncoding: "json"
})
```
To this
```js
var db = level(... {
valueEncoding: require("level-json-coerce-null")
})
```
## Rant
It's quite annoying that javascript has 2 ways of representing "nothing".
* `null` - an object that is meant to represent nothing
* `undefined` - the true nothing (it's also a re-assignable identifier)
WAT!
## License
MIT