This is a local object storage tool written in Node.js.
It allows you to store arbitrary serializable data in json format.
Install the dependencies.
npm installAnd run build to generate two target library for ESModule and CommonJS Module.
npm run build
import the module. This library offers two library for ESM and CommonJS module.
import SimpleOSS from 'simple-oss'; // For ESM
var SimpleOSS = require('simple-oss') // For CommonJS module.And then create an SimpleOSS instance.
const OSS = SimpleOSS.createSimpleOSS('/path/to/storage');The path/to/storage means that the storage directory for data. It stores serialized object data.
And next you can do operators such as set, get and del.
For example, to set an value.
const value = { prop: 'data' }
OSS.set(value,'key-name')And get the value for specified key. It will return null if the key does not exist.
OSS.get('key-name') // { prop: 'data'}
OSS.get('other') // nullTo delete the key-value.
OSS.del('key-name')To check if key-value pair exists
OSS.exist('key-name') // false