Skip to content

db.put(key, undefined....) will give you problems. This codec fixes it.

License

Notifications You must be signed in to change notification settings

smallhelm/level-json-coerce-null

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

level-json-coerce-null

build status

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

var db = level(... {
  valueEncoding: "json"
})

To this

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

About

db.put(key, undefined....) will give you problems. This codec fixes it.

Resources

License

Stars

Watchers

Forks

Packages

No packages published