change talent replace before property allocate

This commit is contained in:
Vick Scarlet
2021-12-14 18:47:05 +08:00
parent f4d7b3ae3c
commit a1e4232369
9 changed files with 48 additions and 27 deletions
+8 -1
View File
@@ -83,10 +83,17 @@ function deepMapSet(target, source) {
return target;
}
function deepGet(obj, path) {
for(const key of path.split('.')) {
if(!(key in obj)) return undefined;
obj = obj[key];
}
return obj;
}
function format(str, ...args) {
const replace = set => (match, key) => {
const value = set[key];
const value = deepGet(set, key);
switch(typeof value) {
case 'object': return JSON.stringify(value);
case 'boolean':