Compare commits

..

No commits in common. "2a1078a3a266922ab2b790678613fd1da1373e68" and "f69a12fb52c757fac5ce7287f58c13120af69ad2" have entirely different histories.

2 changed files with 4 additions and 9 deletions

6
dist/index.js vendored
View File

@ -65,9 +65,7 @@ class Config {
for (const key of Object.keys(settings)) { for (const key of Object.keys(settings)) {
const value = json[key]; const value = json[key];
let keyPath = key.split("."); let keyPath = key.split(".");
let isArray = key.includes(".") && let isArray = typeof parseInt(keyPath.pop()) === "number";
keyPath.length > 1 &&
typeof parseInt(keyPath.pop()) === "number";
if (isArray) { if (isArray) {
let itemPath = keyPath.join("."); let itemPath = keyPath.join(".");
let item = this.get(itemPath, []); let item = this.get(itemPath, []);
@ -129,7 +127,7 @@ class Config {
} }
(0, bsert_1.default)(typeof key === "string", "Key must be a string."); (0, bsert_1.default)(typeof key === "string", "Key must be a string.");
key = this.normalize(key); key = this.normalize(key);
return object_path_1.default.get(this.data, key, fallback); return object_path_1.default.get(this.data, key);
} }
typeOf(key) { typeOf(key) {
const value = this.get(key); const value = this.get(key);

View File

@ -77,10 +77,7 @@ export default class Config {
const value = json[key]; const value = json[key];
let keyPath = key.split("."); let keyPath = key.split(".");
let isArray = let isArray = typeof parseInt(keyPath.pop()) === "number";
key.includes(".") &&
keyPath.length > 1 &&
typeof parseInt(keyPath.pop()) === "number";
if (isArray) { if (isArray) {
let itemPath = keyPath.join("."); let itemPath = keyPath.join(".");
@ -163,7 +160,7 @@ export default class Config {
key = this.normalize(key); key = this.normalize(key);
return objectPath.get(this.data, key, fallback); return objectPath.get(this.data, key);
} }
public typeOf(key: string) { public typeOf(key: string) {