electron-store
Advanced tools
Comparing version 4.0.0 to 5.0.0
/// <reference types="node"/> | ||
import EventEmitter = require('events'); | ||
import {Omit} from 'type-fest'; | ||
import {Except} from 'type-fest'; | ||
import Conf = require('conf'); | ||
declare namespace ElectronStore { | ||
type Options<T> = Omit< | ||
type Schema = Conf.Schema; | ||
type Options<T> = Except< | ||
Conf.Options<T>, | ||
'configName' | 'projectName' | 'projectSuffix' | ||
'configName' | 'projectName' | 'projectVersion' | 'projectSuffix' | ||
> & { | ||
@@ -22,13 +24,27 @@ /** | ||
declare class ElectronStore<T> extends Conf<T> { | ||
/** | ||
Simple data persistence for your [Electron](https://electronjs.org) app or module - Save and load user preferences, app state, cache, etc. | ||
*/ | ||
declare class ElectronStore<T = any> extends Conf<T> { | ||
/** | ||
Simple data persistence for your [Electron](https://electronjs.org) app or module - Save and load user preferences, app state, cache, etc. | ||
Changes are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing store. | ||
Changes are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing config. | ||
@example | ||
``` | ||
import Store = require('electron-store'); | ||
const store = new Store(); | ||
type StoreType = { | ||
isRainbow: boolean, | ||
unicorn?: string | ||
} | ||
const store = new Store<StoreType>({ | ||
defaults: { | ||
isRainbow: true | ||
} | ||
}); | ||
store.get('isRainbow'); | ||
//=> true | ||
store.set('unicorn', '🦄'); | ||
@@ -38,7 +54,2 @@ console.log(store.get('unicorn')); | ||
// Use dot-notation to access nested properties | ||
store.set('foo.bar', true); | ||
console.log(store.get('foo')); | ||
//=> {bar: true} | ||
store.delete('unicorn'); | ||
@@ -45,0 +56,0 @@ console.log(store.get('unicorn')); |
{ | ||
"name": "electron-store", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc", | ||
@@ -36,9 +36,9 @@ "license": "MIT", | ||
"dependencies": { | ||
"conf": "^5.0.0", | ||
"type-fest": "^0.5.2" | ||
"conf": "^6.0.0", | ||
"type-fest": "^0.7.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.1.0", | ||
"electron": "^5.0.5", | ||
"execa": "^1.0.0", | ||
"electron": "^6.0.7", | ||
"execa": "^2.0.4", | ||
"tsd": "^0.7.2", | ||
@@ -45,0 +45,0 @@ "xo": "^0.24.0" |
@@ -23,2 +23,3 @@ # electron-store [![Build Status](https://travis-ci.org/sindresorhus/electron-store.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-store) | ||
const Store = require('electron-store'); | ||
const store = new Store(); | ||
@@ -100,2 +101,31 @@ | ||
### migrations | ||
Type: `object` | ||
You can use migrations to perform operations to the store whenever a version is upgraded. | ||
The `migrations` object should consist of a key-value pair of `version`: `handler`. | ||
Example: | ||
```js | ||
const Store = require('electron-store'); | ||
const store = new Store({ | ||
migrations: { | ||
'0.0.1': store => { | ||
store.set('debug phase', true); | ||
}, | ||
'1.0.0': store => { | ||
store.delete('debug phase'); | ||
store.set('phase', '1.0'); | ||
}, | ||
'1.0.2': store => { | ||
store.set('phase', '>1.0'); | ||
} | ||
} | ||
}); | ||
``` | ||
#### name | ||
@@ -102,0 +132,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14503
78
328
+ Addedconf@6.2.4(transitive)
+ Addeddebounce-fn@3.0.1(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedtype-fest@0.7.1(transitive)
- Removedconf@5.0.0(transitive)
- Removedtype-fest@0.5.2(transitive)
Updatedconf@^6.0.0
Updatedtype-fest@^0.7.1