https://github.com/toinane/electron-light-storage
A lightweight Electron storage package
https://github.com/toinane/electron-light-storage
Last synced: 5 months ago
JSON representation
A lightweight Electron storage package
- Host: GitHub
- URL: https://github.com/toinane/electron-light-storage
- Owner: Toinane
- License: mit
- Created: 2019-03-05T13:55:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T14:29:03.000Z (about 3 years ago)
- Last Synced: 2025-03-20T22:05:24.451Z (about 1 year ago)
- Language: JavaScript
- Size: 258 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-light-storage
> 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!
[](https://nodei.co/npm/electron-light-storage/)
[](https://badge.fury.io/js/electron-light-storage)
[](https://github.com/Toinane/electron-light-storage)
[](https://github.com/Toinane/electron-light-storage)
[](https://github.com/Toinane/electron-light-storage)
[](https://github.com/Toinane/electron-light-storage)
## Installation
`yarn add electron-light-storage`
## Usage
```javascript
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
```json
{
"settings": {
"theme": "dark",
"tabIndent": 4
},
"user": {
"name": "Toinane",
"lastLogin": 1577983073
}
}
```
## API
### storage.set(data: Object): Object
You have to pass only Object in this method.
### storage.get(): Object
It will return you the Object saved.
### storage.reset(): Boolean
It will return a boolean wich is properly reset.
## Licence
MIT @Toinane