Comparing version 0.0.3 to 0.1.0
11
index.js
@@ -50,5 +50,12 @@ 'use strict' | ||
function applyKey (key, retval, options, env) { | ||
function applyKey (_key, retval, options, env) { | ||
let key | ||
if (typeof _key === 'string') { | ||
key = [_key] | ||
} else { | ||
key = _key | ||
} | ||
if (!Array.isArray(key)) { | ||
throw new Error('Key provided is not an array!') | ||
throw new Error('Key provided is not an array or a string!') | ||
} | ||
@@ -55,0 +62,0 @@ |
{ | ||
"name": "fastconf", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "super simple environment-based configuration utility", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,3 +30,3 @@ fastconf | ||
keys: [ | ||
['ZIG_ZAG', {type: String}] | ||
'ZIG_ZAG' // You can also just provide strings (options are defaults) | ||
] | ||
@@ -33,0 +33,0 @@ } |
@@ -62,3 +62,3 @@ 'use strict' | ||
keys: [ | ||
['ZIG_ZAG', {type: String}] | ||
'ZIG_ZAG' | ||
] | ||
@@ -132,6 +132,6 @@ } | ||
test('keys provided must be arrays', t => { | ||
test('keys provided must be arrays or strings', t => { | ||
t.plan(4) | ||
const expectedError = 'Key provided is not an array!' | ||
const expectedError = 'Key provided is not an array or a string!' | ||
@@ -269,1 +269,4 @@ const cases = [ | ||
test.todo('nested call conflict validation') | ||
test.todo('key checking if array') | ||
test.todo('key checking if string') |
14756
377