https://github.com/lzdyes/electron-data-storage
Simple data persistence for Electron app
https://github.com/lzdyes/electron-data-storage
config electron electron-module fs storage typescript
Last synced: 4 months ago
JSON representation
Simple data persistence for Electron app
- Host: GitHub
- URL: https://github.com/lzdyes/electron-data-storage
- Owner: lzdyes
- Created: 2021-06-24T06:14:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-11T06:16:50.000Z (over 4 years ago)
- Last Synced: 2025-09-21T16:25:08.030Z (9 months ago)
- Topics: config, electron, electron-module, fs, storage, typescript
- Language: TypeScript
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# electron-data-storage
> Simple data persistence for Electron app, It's **Thread safety**, Can be called directly from the main process and the renderer process.
[](http://badge.fury.io/js/electron-data-storage)
[](https://github.com/lzdyes/electron-data-storage)
## Installation
```sh
$ npm install electron-data-storage
or
$ yarn add electron-data-storage
```
## Usage
```ts
import storage from 'electron-data-storage'
storage.set('hi', 'Hello World!')
storage.get('hi')
storage.remove('hi')
storage.clear()
```
You can require this module in Electron **main** or **renderer** process.
## API
### set
#### storage.set(key: string, value: string | number | boolean)
```ts
storage.set(key, value)
```
### get
#### storage.get(key: string): string | number | boolean | undefined
```ts
const value = storage.get(key)
console.log(value)
```
### remove
#### storage.remove(key: string)
```ts
storage.remove(key)
```
### clear
#### storage.clear()
```ts
storage.clear()
```
## Tests
Use Jest, edit in **test/index.tset.ts**
```sh
$ yarn test
```
## Contribute
Contributions are welcome! please open issues and pull request :)
## License
The project is licensed under the MIT license.