New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dconf

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dconf

Configuration loader and monitor.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Configuration file loader and monitor for Node.js Build Status

Load and monitor a configuration file.

Installation

npm install dconf

Example

Suppose the following configuration file.

{
    "widget": {
        "debug": "on",
        "window": {
            "height": 500,
            "name": "main_window",
            "title": "Sample Konfabulator Widget",
            "width": 500
        }
    }
}

To load it, one would do:

var dconf = require('dconf');

var config = dconf.loadSync('./config.json');

config.on('error', function(err) {
    console.log(err);
});

config.on('update', function() {
    console.log(util.inspect(config));

    console.log(config.get('widget.debug'));
    console.log(config.get('widget.window.title'));
    console.log(config.get('widget.window.height'));
});

API

Package dconf

dconf.load(filename, callback)
  • filename: configuration file path
  • callback: continuation callback

Asynchronously load a configuration file.

The callback will be called with two arguments (err, config). On error, config will be null and err will contain an error object.

Returns a Config instance (see bellow).

dconf.loadSync(filename)
  • filename: configuration file path

Asynchronously load a configuration file.

Returns a Config instance (see bellow).

Class Config

The Config class isn't intended to be instantiated directly by clients. Use dconf.load or dconf.loadSync to obtain a new instance.

config.get(path, default)
  • path: options path, e.g. foo.bar.biz
  • default: value to use if option isn't specified in config file
config.inspect()

Return a string representing the currently loaded configuration.

config.close()

Stop monitoring the underlying config file and remove all listeners.

Event: 'update'

Emitted when the configuration values are updated, i.e. when the configuration file is successfully reloaded.

Event: 'error'
  • err: error object

Emitted when an error occurs while watching/reading/parsing the config file.

License

This code is free to use under the terms of the MIT license.

Keywords

FAQs

Package last updated on 07 May 2012

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc