feat: add operators option for custom operators

This commit is contained in:
Jason Etcovitch
2021-02-04 09:11:28 +08:00
committed by Jun Yang
parent 5901611af5
commit 75591cdbfc
7 changed files with 65 additions and 53 deletions
+5 -1
View File
@@ -3,7 +3,11 @@ import { Context } from '../context/context'
import { isFunction } from '../util/underscore'
import { isTruthy } from '../render/boolean'
export const operatorImpls: {[key: string]: (lhs: any, rhs: any, ctx: Context) => boolean} = {
export interface OperatorMap {
[key: string]: (lhs: any, rhs: any, ctx: Context) => boolean;
}
export const operatorImpls: OperatorMap = {
'==': (l: any, r: any) => {
if (isComparable(l)) return l.equals(r)
if (isComparable(r)) return r.equals(l)