@moneybutton/config
Advanced tools
Comparing version 0.21.1 to 0.21.2
@@ -1,51 +0,53 @@ | ||
'use strict' | ||
'use strict'; | ||
class Config { | ||
constructor (values) { | ||
this.keyDefined = key => key in values | ||
constructor(values) { | ||
this.keyDefined = key => key in values; | ||
this.getValue = key => values[key] | ||
this.getValue = key => values[key]; | ||
} | ||
get (key) { | ||
get(key) { | ||
if (this.keyDefined(key)) { | ||
return this.getValue(key) | ||
return this.getValue(key); | ||
} else { | ||
throw new Error(`Unknown configuration: ${key}`) | ||
throw new Error(`Unknown configuration: ${key}`); | ||
} | ||
} | ||
} | ||
class MoneyButtonConfigBuilder { | ||
constructor () { | ||
this.variables = {} | ||
constructor() { | ||
this.variables = {}; | ||
} | ||
build () { | ||
return new Config(this.variables) | ||
build() { | ||
return new Config(this.variables); | ||
} | ||
addValue (key, value) { | ||
addValue(key, value) { | ||
if (value === undefined) { | ||
throw new Error(`Failed to add "${key}" property. The value cannot be undefined`) | ||
throw new Error(`Failed to add "${key}" property. The value cannot be undefined`); | ||
} | ||
if (key in this.variables) { | ||
throw new Error(`"${key}" already has a value defined.`) | ||
throw new Error(`"${key}" already has a value defined.`); | ||
} | ||
this.variables[key] = value | ||
return this | ||
this.variables[key] = value; | ||
return this; | ||
} | ||
addValueWithDefault (key, value, defaultValue) { | ||
addValueWithDefault(key, value, defaultValue) { | ||
if (defaultValue === undefined) { | ||
throw new Error(`Failed to add "${key}" property. Default value cannot be undefined`) | ||
throw new Error(`Failed to add "${key}" property. Default value cannot be undefined`); | ||
} | ||
return this.addValue(key, value === undefined ? defaultValue : value) | ||
return this.addValue(key, value === undefined ? defaultValue : value); | ||
} | ||
} | ||
module.exports = MoneyButtonConfigBuilder | ||
// # sourceMappingURL=moneybutton.config.cjs.js.map | ||
module.exports = MoneyButtonConfigBuilder; | ||
//# sourceMappingURL=moneybutton.config.cjs.js.map |
class Config { | ||
constructor (values) { | ||
this.keyDefined = key => key in values | ||
constructor(values) { | ||
this.keyDefined = key => key in values; | ||
this.getValue = key => values[key] | ||
this.getValue = key => values[key]; | ||
} | ||
get (key) { | ||
get(key) { | ||
if (this.keyDefined(key)) { | ||
return this.getValue(key) | ||
return this.getValue(key); | ||
} else { | ||
throw new Error(`Unknown configuration: ${key}`) | ||
throw new Error(`Unknown configuration: ${key}`); | ||
} | ||
} | ||
} | ||
class MoneyButtonConfigBuilder { | ||
constructor () { | ||
this.variables = {} | ||
constructor() { | ||
this.variables = {}; | ||
} | ||
build () { | ||
return new Config(this.variables) | ||
build() { | ||
return new Config(this.variables); | ||
} | ||
addValue (key, value) { | ||
addValue(key, value) { | ||
if (value === undefined) { | ||
throw new Error(`Failed to add "${key}" property. The value cannot be undefined`) | ||
throw new Error(`Failed to add "${key}" property. The value cannot be undefined`); | ||
} | ||
if (key in this.variables) { | ||
throw new Error(`"${key}" already has a value defined.`) | ||
throw new Error(`"${key}" already has a value defined.`); | ||
} | ||
this.variables[key] = value | ||
return this | ||
this.variables[key] = value; | ||
return this; | ||
} | ||
addValueWithDefault (key, value, defaultValue) { | ||
addValueWithDefault(key, value, defaultValue) { | ||
if (defaultValue === undefined) { | ||
throw new Error(`Failed to add "${key}" property. Default value cannot be undefined`) | ||
throw new Error(`Failed to add "${key}" property. Default value cannot be undefined`); | ||
} | ||
return this.addValue(key, value === undefined ? defaultValue : value) | ||
return this.addValue(key, value === undefined ? defaultValue : value); | ||
} | ||
} | ||
export default MoneyButtonConfigBuilder | ||
// # sourceMappingURL=moneybutton.esm.js.map | ||
export default MoneyButtonConfigBuilder; | ||
//# sourceMappingURL=moneybutton.esm.js.map |
{ | ||
"name": "@moneybutton/config", | ||
"version": "0.21.1", | ||
"version": "0.21.2", | ||
"description": "Money Button configuration.", | ||
@@ -5,0 +5,0 @@ "main": "dist/moneybutton.config.cjs.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
106071
0
98