strongermap
v1.0.0
Published
A extended version of `Map` that allows you to keep data persistent with the help of JSON.
Downloads
73
Readme
StrongMap
A extended version of Map
that allows you to keep data persistent with the help of JSON.
const { StrongMap } = require('strongermap');
/**
* @param {string} name - Name of the JSON file
* @param {boolean} writeOnOperation - Determines whether this will write on every operation
* @param {string} path - Path of the JSON file.
*/
const persistent = new PersistentMap(name, writeOnOperation, path);
It you call the same functions as a normal map, the only difference being that at the end of it all, you can call the write
method to save your data.
persistent.write()
By default writeOnOperation
is off, so it's up to you to manually write when you need to, whether it be through a setTimeout()
or other means.
To load in data from another JSON, well, just copy it I guess. I'll do something about that later.