Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-store

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-store - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

19

index.js

@@ -7,16 +7,19 @@ 'use strict';

class ElectronStore extends Conf {
constructor(opts) {
constructor(options) {
const defaultCwd = (electron.app || electron.remote.app).getPath('userData');
opts = Object.assign({name: 'config'}, opts);
options = {
name: 'config',
...options
};
if (opts.cwd) {
opts.cwd = path.isAbsolute(opts.cwd) ? opts.cwd : path.join(defaultCwd, opts.cwd);
if (options.cwd) {
options.cwd = path.isAbsolute(options.cwd) ? options.cwd : path.join(defaultCwd, options.cwd);
} else {
opts.cwd = defaultCwd;
options.cwd = defaultCwd;
}
opts.configName = opts.name;
delete opts.name;
super(opts);
options.configName = options.name;
delete options.name;
super(options);
}

@@ -23,0 +26,0 @@

{
"name": "electron-store",
"version": "2.0.0",
"version": "3.0.0",
"description": "Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc",

@@ -35,9 +35,9 @@ "license": "MIT",

"dependencies": {
"conf": "^2.0.0"
"conf": "^3.0.0"
},
"devDependencies": {
"ava": "*",
"electron": "^2.0.2",
"execa": "^0.10.0",
"xo": "*"
"ava": "^1.3.1",
"electron": "^4.1.1",
"execa": "^1.0.0",
"xo": "^0.24.0"
},

@@ -44,0 +44,0 @@ "xo": {

@@ -1,2 +0,2 @@

# electron-store [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/electron-store.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-store) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/m2m9o6gq77xxi2eg/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/electron-store/branch/master)
# electron-store [![Build Status](https://travis-ci.org/sindresorhus/electron-store.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-store)

@@ -9,5 +9,3 @@ > Simple data persistence for your [Electron](https://electronjs.org) app or module - Save and load user preferences, app state, cache, etc

*[This project was previously known as `electron-config`.](https://github.com/sindresorhus/electron-store/issues/4)*
## Install

@@ -19,5 +17,9 @@

*Requires Electron 2.0.0 or later.*
*Requires Electron 4 or later.*
<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>
## Usage

@@ -54,2 +56,4 @@

Type: `Object`
#### defaults

@@ -94,3 +98,3 @@

type: `string`<br>
Type: `string`<br>
Default: `json`

@@ -102,2 +106,27 @@

#### clearInvalidConfig
Type: `boolean`<br>
Default: `true`
The config is cleared if reading the config file causes a `SyntaxError`. This is a good default, as the config file is not intended to be hand-edited, so it usually means the config is corrupt and there's nothing the user can do about it anyway. However, if you let the user edit the config file directly, mistakes might happen and it could be more useful to throw an error when the config is invalid instead of clearing. Disabling this option will make it throw a `SyntaxError` on invalid config instead of clearing.
#### serialize
Type: `Function`<br>
Default: `value => JSON.stringify(value, null, '\t')`
Function to serialize the config object to a UTF-8 string when writing the config file.
You would usually not need this, but it could be useful if you want to use a format other than JSON.
#### deserialize
Type: `Function`<br>
Default: `JSON.parse`
Function to deserialize the config object from a UTF-8 string when reading the config file.
You would usually not need this, but it could be useful if you want to use a format other than JSON.
### Instance

@@ -113,3 +142,3 @@

The `value` must be JSON serializable.
The `value` must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a TypeError.

@@ -142,2 +171,4 @@ #### .set(object)

Events are only triggered in the same process. So you won't get events in the main process if you trigger an event in a renderer process. See [#39](https://github.com/sindresorhus/electron-store/issues/39).
#### .size

@@ -168,7 +199,25 @@

- [Advantages over `window.localStorage`](https://github.com/sindresorhus/electron-store/issues/17)
### [Advantages over `window.localStorage`](https://github.com/sindresorhus/electron-store/issues/17)
### Can I use YAML or another serialization format?
The `serialize` and `deserialize` options can be used to customize the format of the config file, as long as the representation is compatible with `utf8` encoding.
Example using YAML:
```js
const Store = require('electron-store');
const yaml = require('js-yaml');
const store = new Store({
fileExtension: 'yaml',
serialize: yaml.safeDump,
deserialize: yaml.safeLoad
});
```
## Related
- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps and modules
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app

@@ -178,2 +227,4 @@ - [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app

- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app
- [electron-reloader](https://github.com/sindresorhus/electron-reloader) - Simple auto-reloading for Electron apps during development
- [electron-serve](https://github.com/sindresorhus/electron-serve) - Static file serving for Electron apps
- [conf](https://github.com/sindresorhus/conf) - Simple config handling for your app or module

@@ -180,0 +231,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc