GitXplorerGitXplorer
j

nano-config

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
eee32baa245d3ce5f9faff72b2f086446cebc1b3

Merge pull request #1 from jamesrom/jamesrom-patch-1

jjamesrom committed 6 years ago
Verified
437a8b7d8630b32eb4e0de791328ccbfe41c9bb8

Update readme.md

jjamesrom committed 6 years ago
Unverified
0e63ccfec9961a3f868046f3bb5b89197964da11

Fix header image

jjamesrom committed 8 years ago
Unverified
9e3d6585168c4fe3cb9bbadfa4fe804beab538b9

Update nano-config.js

jjamesrom committed 8 years ago
Unverified
32e8b0493ae208209bb369bda44c9150a792e71d

Fixed link in readme.md

jjamesrom committed 10 years ago
Unverified
b1f818bce77e9c952ed00de13c20ea64a7064d92

bumped version number

jjamesrom committed 11 years ago

README

The README file for this repository.

nano-config logo

A simple, dependency-free configuration helper with a nano API.

var config = require('nano-config')('./my-configuration.json');
config.greet = 'world';
config.save()

Loads my-configuration.json. If it doesn't exist it will be created when you call save.

{
  "greet": "world"
}

Okay, cool. You just saved some JSON. Who cares?

It's global

You only need to load a configuration file once. Here's some other part of your application.

var config = require('nano-config');
console.log(`hello ${config.greet}`);

Outputs

hello world

nano-config remembers the last config you loaded.

It's simple

nano-config doesn't depend on any modules, doesn't care about environment variables and doesn't have a verbose API.

Do you need to load a specific configuration file for a specific environment? Do it yourself.

var config = require('nano-config')(`./${process.env.NODE_ENV}.json`)

It's flexible

Custom serialization. Prefer CSON?

var CSON = require('cson');
var config = require('nano-config');
config.deserialize = str => CSON.parseSync(str);
config.serialize = obj => CSON.stringifySync(obj);
config('./my-config.cson');

Full API Documentation

config(file)

Loads a configuration file.

config.save(callback)

Saves the current configuration to file. Optional callback is called when save is finished.

config.serialize(obj)

The object serializer. It takes an object and returns a string.

config.deserialize(string)

The string deserializer. It takes a string and returns an object.