Comparing version 0.1.1 to 0.2.1
'use strict' | ||
module.exports = function fastconf (options, namespaces, envOverride) { | ||
module.exports = function fastconf (_options, namespaces, envOverride) { | ||
let options | ||
if (Array.isArray(_options)) { | ||
options = {keys: _options} | ||
} else { | ||
options = _options | ||
} | ||
if (!options || typeof options !== 'object') { | ||
@@ -5,0 +12,0 @@ throw new Error('No options object provided!') |
{ | ||
"name": "fastconf", | ||
"version": "0.1.1", | ||
"version": "0.2.1", | ||
"description": "super simple environment-based configuration utility", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,13 +20,13 @@ fastconf | ||
const config = fastconf({ | ||
keys: [ | ||
['FOO_BAR', {type: Number}], | ||
['NOPE', {type: Boolean, defaultValue: false}], | ||
['MORE_THINGS', {defaultValue: 'apples'}] | ||
] | ||
}, { | ||
xbpf: { | ||
const config = fastconf([ | ||
// All keys are required unless a default value is provided | ||
['FOO_BAR', {type: Number}], | ||
['NOPE', {type: Boolean, defaultValue: false}], | ||
['MORE_THINGS', {defaultValue: 'apples'}] | ||
], { | ||
xbpf: { // You can also pass an object (with the keys prop) if you want to | ||
// further configure fastconf | ||
prefix: 'XBPF_', | ||
keys: [ | ||
'ZIG_ZAG' // You can also just provide strings (options are defaults) | ||
'ZIG_ZAG' // You can also just provide strings in keys array (options are defaults) | ||
] | ||
@@ -59,2 +59,5 @@ } | ||
const config = fastconf({ | ||
// (Since 0.2.0) You can now just pass an array in place of the first object, | ||
// which is equivalent to passing {keys: [the array]} | ||
// Prefix, useful for not having to repeat yourself. | ||
@@ -61,0 +64,0 @@ // If you have a prefix of 'NICE_', and have a required key 'FOO_BAR', |
13
test.js
@@ -52,9 +52,7 @@ 'use strict' | ||
const config = fastconf({ | ||
keys: [ | ||
['FOO_BAR', {type: Number}], | ||
['NOPE', {type: Boolean, defaultValue: false}], | ||
['MORE_THINGS', {defaultValue: 'apples'}] | ||
] | ||
}, { | ||
const config = fastconf([ | ||
['FOO_BAR', {type: Number}], | ||
['NOPE', {type: Boolean, defaultValue: false}], | ||
['MORE_THINGS', {defaultValue: 'apples'}] | ||
], { | ||
xbpf: { | ||
@@ -271,1 +269,2 @@ prefix: 'XBPF_', | ||
test.todo('key checking if string') | ||
test.todo('array of keys for options testing') |
15320
382
155