Compare commits
3 Commits
17a434f400
...
e1d4785240
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | e1d4785240 | |
Derrick Hammer | 9e8e44b9c5 | |
Derrick Hammer | 792ec3976f |
|
@ -64,17 +64,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +88,6 @@ 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.");
|
||||
|
|
17
src/index.ts
17
src/index.ts
|
@ -75,21 +75,6 @@ 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);
|
||||
}
|
||||
}
|
||||
|
@ -123,8 +108,6 @@ export default class Config {
|
|||
key = this.normalize(key);
|
||||
|
||||
objectPath.set(this.data, key, value);
|
||||
|
||||
this.data[key] = value;
|
||||
}
|
||||
|
||||
public has(key: string) {
|
||||
|
|
Loading…
Reference in New Issue