Compare commits

..

No commits in common. "e1d4785240c3815a5b0e376e96e0fb0edfd0c064" and "17a434f400f6425b854a8c1ff28af47e44b557f5" have entirely different histories.

2 changed files with 29 additions and 0 deletions

12
dist/index.js vendored
View File

@ -64,6 +64,17 @@ class Config {
const settings = (0, deep_to_flat_object_1.default)(json);
for (const key of Object.keys(settings)) {
const value = settings[key];
let keyPath = key.split(".");
let isArray = key.includes(".") &&
keyPath.length > 1 &&
typeof parseInt(keyPath.pop()) === "number";
if (isArray) {
let itemPath = keyPath.join(".");
let item = this.get(itemPath, []);
item.push(value);
this.set(itemPath, item);
continue;
}
this.set(key, value);
}
}
@ -88,6 +99,7 @@ class Config {
}
key = this.normalize(key);
object_path_1.default.set(this.data, key, value);
this.data[key] = value;
}
has(key) {
(0, bsert_1.default)(typeof key === "string", "Key must be a string.");

View File

@ -75,6 +75,21 @@ export default class Config {
for (const key of Object.keys(settings)) {
const value = settings[key];
let keyPath = key.split(".");
let isArray =
key.includes(".") &&
keyPath.length > 1 &&
typeof parseInt(keyPath.pop()) === "number";
if (isArray) {
let itemPath = keyPath.join(".");
let item = this.get(itemPath, []);
item.push(value);
this.set(itemPath, item);
continue;
}
this.set(key, value);
}
}
@ -108,6 +123,8 @@ export default class Config {
key = this.normalize(key);
objectPath.set(this.data, key, value);
this.data[key] = value;
}
public has(key: string) {