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

electron-settings

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-settings - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

43

lib/settings.js

@@ -81,3 +81,3 @@ /**

fs.ensureFileSync(this._configFilePath);
this._init();
};

@@ -91,2 +91,43 @@

/**
* Initialize the ElectronSettings instance.
*
* @private
*/
internals.ElectronSettings.prototype._init = function () {
this._ensure();
this._setInitialSettings();
};
/**
* Ensures the config file exists.
*
* @private
*/
internals.ElectronSettings.prototype._ensure = function () {
fs.ensureFileSync(this._configFilePath);
};
/**
* Sets the initial settings value.
*
* @private
*/
internals.ElectronSettings.prototype._setInitialSettings = function () {
this._settings = this._read() || {};
};
/**
* Reads settings from disk.
*
* @private
*/
internals.ElectronSettings.prototype._read = function () {
try {
return fs.readJsonSync(this._configFilePath);
} catch (err) {
return null;
}
};
/**
* Emits a change event.

@@ -93,0 +134,0 @@ *

2

package.json
{
"name": "electron-settings",
"version": "0.0.1",
"version": "0.0.2",
"description": "User settings manager for Electron",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,3 @@ # Electron-Settings

|key|type|description|default|
|Key|Type|Description|Default|
|--:|:--:|:----------|:-----:|

@@ -16,6 +16,6 @@ |`shouldSave`|`boolean`|Whether we should save changes to disk.|`true`|

* [`set`](#set)
* [`get`](#get)
* [`unset`](#unset)
* [`getUserConfigPath`](#getUserConfigPath)
* [`set`](#setkeypath-value-options)
* [`get`](#getkeypathobject)
* [`unset`](#unsetkeypath-options)
* [`getUserConfigPath`](#getuserconfigpathstring)

@@ -29,3 +29,3 @@ ***

#### Parameters
|parameter|type|description|required|default|
|Parameter|Type|Description|Required|Default|
|--------:|:--:|:----------|:------:|:-----:|

@@ -58,3 +58,3 @@ |`keyPath`|`string`|The key-path.|✓|

```
3. Overwrite settings without defining a key-path.
3. Advanced example with basic key-path and complex value.
```js

@@ -64,2 +64,16 @@ let ElectronSettings = require('electron-settings');

settings.set('foo', {
snap: {
crackle: 'pop'
}
});
console.log(settings.get());
// => { foo: { snap: { crackle: 'pop' } } }
```
4. Overwrite settings without defining a key-path.
```js
let ElectronSettings = require('electron-settings');
let settings = new ElectronSettings();
// This will overwrite any pre-existing settings.

@@ -81,5 +95,5 @@ settings.set({

#### Parameters
|parameter|type|description|required|default|
|Parameter|Type|Description|Required|Default|
|--------:|:--:|:----------|:------:|:-----:|
|`keyPath`|`string`|The key-path.||`''`|
|`keyPath`|`string`|The key-path.|

@@ -126,3 +140,3 @@ #### Examples

#### Parameters
|parameter|type|description|required|default|
|Parameter|Type|Description|Required|Default|
|--------:|:--:|:----------|:------:|:-----:|

@@ -129,0 +143,0 @@ |`keyPath`|`string`|The key-path.|✓|

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