Skip to content

lzdyes/electron-data-storage

Repository files navigation

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.

npm version license

Installation

$ npm install electron-data-storage

or

$ yarn add electron-data-storage

Usage

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)

storage.set(key, value)

get

storage.get(key: string): string | number | boolean | undefined

const value = storage.get(key)
console.log(value)

remove

storage.remove(key: string)

storage.remove(key)

clear

storage.clear()

storage.clear()

Tests

Use Jest, edit in test/index.tset.ts

$ yarn test

Contribute

Contributions are welcome! please open issues and pull request :)

License

The project is licensed under the MIT license.