refac: SammoAPI Path 정의에 NumVar, StrVar 추가

This commit is contained in:
2022-03-25 23:29:10 +09:00
parent 11e28b7a87
commit 00ceb3f842
5 changed files with 51 additions and 33 deletions
+10
View File
@@ -1,6 +1,12 @@
export function APIPathGen(obj, callback, path) {
return new Proxy(obj, {
get(target, key) {
if(typeof key === 'number'){
key = key.toString();
}
else if(typeof key !== 'string'){
throw `${key} is not string`;
}
let nextPath;
if (path === undefined) {
nextPath = [key];
@@ -21,4 +27,8 @@ export function APIPathGen(obj, callback, path) {
return APIPathGen(next, callback, nextPath);
}
})
}
export function StrVar(){
return (next)=>next;
}