Socket
Socket
Sign inDemoInstall

electron-json-config

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    electron-json-config

Simply set and get configuration from a json file for your Electron app


Version published
Maintainers
1
Install size
5.60 kB
Created

Readme

Source

electron-json-config

Simply set and get configuration from a json file for your Electron app

The config file (config.json) is located in the path returned by app.getPath('userData').
This package can be used from browser and renderer process.

Usage

const config = require('electron-json-config');

config.set('foo', 'bar');
console.log(config.get('foo')); // shows 'bar'

API

All key can be a classic key (eg: foo) or a multiple level key with levels separated by . (eg: foo.bar)

config.file()

Returns the name of the file the config is stored in.

config.has(key)

Returns true if the key exists, false otherwise.

config.set(key, value)

Set a key with the specified value. If the key is already in use its value will be overwritten.

config.get(key[, defaultValue])

Returns the value associated with the key. If the key is not defined undefined is returned.
You can specify a default value returned in case the key does not exists.

config.keys([key])

If key is provided, returns an array containing all keys if the key object.
If key is omitted, returns an array containing all keys in the config file.

config.all()

Returns an object with all the data currently saved.

config.delete(key)

Remove the key and its value from the config file.

config.purge()

Remove all data from the config file.

Keywords

FAQs

Last updated on 18 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc