import { createVal } from "./val" ; import { createRegx } from "./regx" ; import { createPrim } from "./prim" ; import { createDeep } from "./deep" ; import { identity , isDeepVal , isFunction , isPrimative , isPDSLSchema , isRegEx } from "../lib/utils" ; function createExpressionParser ( ctx , expression ) { if ( isFunction ( expression ) ) { if ( isPrimative ( expression ) ) return createPrim ( ctx ) ; return identity ; } if ( isPDSLSchema ( expression ) ) { return expression => expression . unsafe_predicate ; } if ( isRegEx ( expression ) ) return createRegx ( ctx ) ; if ( isDeepVal ( expression ) ) return createDeep ( ctx ) ; return createVal ( ctx ) ; } param { * } input return { function } export const createPred = ctx => function pred ( input ) { const expParser = createExpressionParser ( ctx , input ) ; return expParser ( input ) ; } ;