Use physical JSON files as a key value store
const jsonkvs = require('jsonkvs') const packageJson = jsonkvs('./myFile.json') packageJson.set('one', 'some value') packageJson.del('someKey') packageJson.save() // write changes
|tabSpace||'\t'||What character to use to indent output JSON. Defaults to hard tab.|
Load a JSON file at a given
Get the value of a given
key. If no
key is passed will return the whole object.
.set(key, value | patch, replace=false)
value of a given
key. Can be called two ways:
- By passing the
keyas first argument and
- By passing an
patchobject. In this case the patch will be merged. If
replaceis set then the original file will be overridden by the patch
Unset a given keys
Commit changes to disk
- When a file is open it's contents is loaded into memory and it's not locked.
- If the file changes on the FS it's contents should be reread and memory copy updated.
- Any pending changes in memory will superseed new changes from disk.
- The above bollocks should all be configurable (you can lock a file, get/set directly from the file (via inmemory cache), conflict resolution)
- Can save to an alternative location
Copyright (c) 2017, Infracloud Ltd All rights reserved.