You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to support case-insensitive property getter so user doesn't need to know exact case. Based on your suggestion on that ticket, we created our own EvalAstFactory but we need to override three methods even though all of them would call one common function. I think it is better if you can provide a new API getValue (or some other name) which is supposed to return value for a given object and property name, we can override just that method instead of 3 methods as shown below.
functiongetValueIgnoreCase(obj: RealAny,name: string): RealAny{if(obj==undefined||!name){returnundefined;}letvalue=obj[name];if(value==undefined){constnameLower=(name+'').toLowerCase();for(constkeyofObject.keys(obj)){if(key.toLowerCase()===nameLower){value=obj[key];break;}}}returnvalue;}classCustomEvalFactoryextendsEvalAstFactory{overrideid(v: string): ID{return{type: 'ID',value: v,evaluate(scope){// TODO(justinfagnani): this prevents access to properties named 'this'if(this.value==='this')returnscope;returngetValueIgnoreCase(scope,this.value);},getIds(idents){idents.push(this.value);returnidents;},};}overridegetter(g: Expression,n: string): Getter{return{type: 'Getter',receiver: g,name: n,evaluate(scope){returngetValueIgnoreCase(this.receiver.evaluate(scope),this.name);},getIds(idents){this.receiver.getIds(idents);returnidents;},};}overrideindex(e: Expression,a: Expression): Index{return{type: 'Index',receiver: e,argument: a,evaluate(scope){returngetValueIgnoreCase(this.receiver.evaluate(scope),this.argument.evaluate(scope));},getIds(idents){this.receiver.getIds(idents);returnidents;},};}}
The text was updated successfully, but these errors were encountered:
Ref: justinfagnani/jexpr#13
We want to support case-insensitive property getter so user doesn't need to know exact case. Based on your suggestion on that ticket, we created our own EvalAstFactory but we need to override three methods even though all of them would call one common function. I think it is better if you can provide a new API
getValue
(or some other name) which is supposed to return value for a given object and property name, we can override just that method instead of 3 methods as shown below.The text was updated successfully, but these errors were encountered: