@appruut/config
Version:
Config file manager for Node.js
30 lines (29 loc) • 882 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const node_utils_1 = require("@appruut/node-utils");
class Config {
constructor(config = {}) {
this.config = config;
}
all() {
return this.config;
}
get(key, defaultValue) {
return node_utils_1.lodash.get(this.config, key, defaultValue);
}
merge(key, defaultValues, customizer) {
return node_utils_1.lodash.mergeWith(defaultValues, this.get(key), customizer);
}
defaults(key, value) {
const existingValue = this.get(key);
if (existingValue) {
node_utils_1.lodash.mergeWith(value, existingValue);
}
this.set(key, value);
}
set(key, value) {
node_utils_1.lodash.set(this.config, key, value);
}
}
exports.Config = Config;