Lightweight Electron storage package
You probably need to save data for your Electron application. But you don't want a package that's too elaborate. That's good because I needed a small package with no dependency to allow me that, this is the purpose of this package!
yarn add electron-light-storage
const Storage = require('electron-light-storage');
const store = new Storage();
// Set storage
store.set({ say: 'hi Github!' });
// Get storage
store.get();
//=> { 'say': 'hi Github!' }
// Get storage from name
store.get('say');
//=> 'hi Github!'
// Set API just update the previous store with a deep merge, use reset API to remove all
store.set({ user: 'Toinane' });
//=> { 'say': 'hi Github!', 'user': 'Toinane' }
// Reset storage (this API delete the file & create new storage file)
store.reset();
//=> {}
this API is useful for minimal storage like this configuration object
{
"settings": {
"theme": "dark",
"tabIndent": 4
},
"user": {
"name": "Toinane",
"lastLogin": 1577983073
}
}
You have to pass only Object in this method.
It will return you the Object saved.
It will return a boolean wich is properly reset.
MIT @Toinane