Comparing version 0.0.0 to 0.0.1
@@ -9,11 +9,2 @@ /*! | ||
const Config = require('./config'); | ||
function bcfg(module, options) { | ||
return new Config(module, options); | ||
} | ||
bcfg.config = bcfg; | ||
bcfg.Config = Config; | ||
module.exports = bcfg; | ||
module.exports = require('./config'); |
@@ -149,2 +149,27 @@ /*! | ||
/** | ||
* Create a child config. Filter by plugin name. | ||
* @param {String} name | ||
* @returns {Config} | ||
*/ | ||
filter(name) { | ||
assert(typeof name === 'string'); | ||
const child = new Config(this.module); | ||
child.prefix = this.prefix; | ||
child.suffix = this.suffix; | ||
child.fallback = this.fallback; | ||
child.argv = this.argv; | ||
child.pass = this.pass; | ||
_filter(name, this.env, child.env); | ||
_filter(name, this.args, child.args); | ||
_filter(name, this.query, child.query); | ||
_filter(name, this.hash, child.hash); | ||
return child; | ||
} | ||
/** | ||
* Set default option. | ||
@@ -990,3 +1015,3 @@ * @param {String} key | ||
return this.parseForm(query, this.query); | ||
return this.parseForm(query, '?', this.query); | ||
} | ||
@@ -1011,3 +1036,3 @@ | ||
return this.parseForm(hash, this.hash); | ||
return this.parseForm(hash, '#', this.hash); | ||
} | ||
@@ -1019,5 +1044,7 @@ | ||
* @param {String} query | ||
* @param {String} ch | ||
* @param {Object} map | ||
*/ | ||
parseForm(query, map) { | ||
parseForm(query, ch, map) { | ||
assert(typeof query === 'string'); | ||
@@ -1028,7 +1055,2 @@ | ||
let ch = '?'; | ||
if (map === this.hash) | ||
ch = '#'; | ||
if (query[0] === ch) | ||
@@ -1117,2 +1139,11 @@ query = query.substring(1); | ||
function _filter(name, a, b) { | ||
for (const key of Object.keys(a)) { | ||
if (key.length > name.length && key.indexOf(name) === 0) { | ||
const sub = key.substring(name.length); | ||
b[sub] = a[key]; | ||
} | ||
} | ||
} | ||
function fromFloat(num, exp) { | ||
@@ -1122,4 +1153,3 @@ assert(typeof num === 'number' && isFinite(num)); | ||
const str = num.toFixed(exp); | ||
let str = num.toFixed(exp); | ||
let sign = 1; | ||
@@ -1126,0 +1156,0 @@ |
{ | ||
"name": "bcfg", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Config parser for bcoin", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"babelify": "^7.3.0", | ||
"babelify": "^8.0.0", | ||
"babel-core": "^6.26.0", | ||
@@ -31,8 +31,7 @@ "babel-loader": "^7.1.2", | ||
"browserify": "^14.5.0", | ||
"eslint": "^4.9.0", | ||
"level-js": "^2.2.4", | ||
"eslint": "^4.14.0", | ||
"mocha": "^4.0.1", | ||
"uglifyjs-webpack-plugin": "^1.0.0-beta.3", | ||
"uglifyjs-webpack-plugin": "^1.1.5", | ||
"uglify-es": "^3.1.3", | ||
"webpack": "^3.8.1" | ||
"webpack": "^3.10.0" | ||
}, | ||
@@ -39,0 +38,0 @@ "engines": { |
@@ -8,5 +8,6 @@ # bcfg | ||
``` js | ||
const bcfg = require('bcfg'); | ||
const Config = require('bcfg'); | ||
const config = bcfg('my-module', { | ||
// Will consider ~/.my-module the prefix directory. | ||
const config = new Config('my-module', { | ||
alias: { | ||
@@ -13,0 +14,0 @@ 'n': 'network' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30443
10
11
1030
56