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

lconf

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

lconf

parse local configuration files of various types

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

lconf Build Status

parse local configuration files of various types. currently supported filetypes: json,yaml,yml,js (must module.exports = {};)

api

lconf supports three methods:

  • parse(file:string):
    parses a configuration file located at file. note: file must be a path fs recognizes, so be sure to use ./ when needed.

  • suppress(bool:boolean[default=true]):
    toggles throwing of exceptions when parsing. using suppress() will prevent throwing of errors.

  • opts():
    does the actual parse, and throws errors if there are any, and we aren't suppress()-ed.

these methods can be chained together:

var lconf = require('lconf');

// parse multiple configuration files
var config = lconf().parse('./config.yaml').parse('./config.json').opts();

the resulting object will look like:

{
  "./config.yaml": {...},
  "./config.json": {...}
}

If you want to smash configuration variables into one object, see bengreenier/hulksmash.

examples

parse some config files that may or may not be present:

var lconf = require('lconf');

// parse multiple configuration files
var config = lconf()
              .parse('./idk.yaml')
              .parse('./if.json')
              .parse('./these.json')
              .parse('./are.json')
              .parse('./present.js')
              .suppress()
              .opts();

// could check config object keys to see what succeeded

reuse parsing instance:

var lconf = require('lconf');

// parse multiple configuration files
var parser = lconf();

var config = parser
              .parse('./config.yaml')
              .parse('./config.json')
              .opts();

var settings = parser
              .parse('./settings.yaml')
              .parse('./settings.json')
              .opts();

// config will have two keys (one for each .parse() filename)
// settings will have two as well.
// each call to .opts() clears previously parsed data

Keywords

FAQs

Package last updated on 27 Jan 2015

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