1.2.0 • Published 3 years ago

electron-json-storage-sync v1.2.0

Weekly downloads
400
License
MIT
Repository
github
Last release
3 years ago

electron-json-storage-sync

Synchronously write and read user settings in Electron apps

This is a synchronous version of electron-json-storage. Credits to jviotti for writing the original async version. Version 1.1.0 implements methods get, set, has, keys, remove and clear.

Installation

Install electron-json-storage-sync by running:

$ npm install --save electron-json-storage-sync

You can require this module from either the main or renderer process (with and without remote).

Documentation

Storage module

const storage = require('electron-json-storage-sync');

.get(key)

const result = storage.get('foo');
if (result.status) {
  // do something with result.data
} else {
  // handle result.error
}

.set(key, data)

const result = storage.set('foo', {bar:'baz'});
if (result.status) {
  // data has been stored
} else {
  // handle result.error
}

.has()

const result = storage.has('foo');
if (result.status && result.data) {
  // key in storage
} else if (result.status && !result.data){
  // key not in storage
} else {
  // handle result.error
}

.keys()

const result = storage.keys();
if (result.status) {
  // do something with array result.data
} else {
  // handle result.error
}

.remove(key)

const result = storage.remove();
if (result.status) {
  // the storage record has been removed
} else {
  // handle result.error
}

.clear()

const result = storage.clear();
if (result.status) {
  // storage has been cleared
} else {
  // handle result.error
}
1.2.0

3 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago