A data storing library that lets you to store data in a JSON file.
PeristenceManager was created to store data on one JSON file, called a persistence. It was designed to only use the native node.js dependecies. Inside the persistence are stored the container objects, which contain the saved data. Each container contains a metadata object and a data array.
const PersistenceLib = require('PersistenceManager');
const Manager = PersistenceLib.Manager();
var PersistenceContainer = Manager.createPersistence("TempSave",[5,10,15,"StringElement"]);
PersistenceContainer.addElement(null,20,25,30,"NewStringElement");
PersistenceContainer.addElement("ArrayKey",5,10,15,"StringElement";
console.log(PersistenceContainer.container); // [ 5, 10, 15, "StringElement", 20, 25, 30, "NewStringElement", ["ArrayKey"]: [ 5, 10, 15, "StringElement" ]]
PersistenceContainer.removePersistence("TempSave");
console.log(PersistenceContainer); // undefined
new PersistenceLib.Manager(SaveName,InitData):class Manager
Creates a new Persistance Manager which is used to handle the storing and retrieving of the saved data.
- SaveName[string]: The name used for the storage file.
- InitData[any]: [Optional] The data the storage will begin with.
Return Type: Container Array
.addElement(Key,...Elements):array Container
Adds elements to the save file and container. Returns the data array.
- Key[string or null]: The key that will be used to index the elements. If null, elements will be pushed in the array.
- Elements[...any]: The elements to be inserted into the array.
.removeContainer():void
Removes entirely the container and destroys the Manager.
Return Type: Container Array
Summary: Returns the deleted container.