electron-settings
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -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 @@ * |
{ | ||
"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.|✓| |
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
17837
372
202