| 87 | says: Says | undefined = saysOf(this.meta, this.predicate) |
| 88 | |
| 89 | tApply(data: unknown, ctx: InternalTraversal): void { |
| 90 | const errN = ctx.errN |
| 91 | const predicate = this.predicate |
| 92 | const label = this.meta.label |
| 93 | const says = this.says |
| 94 | // set aside, as a labeled callback applying this node to its own ctx |
| 95 | // still names its value in what it raises after |
| 96 | let outer: string | undefined |
| 97 | if (label !== undefined) { |
| 98 | outer = ctx.lbl |
| 99 | ctx.lbl = label |
| 100 | } |
| 101 | const valid = |
| 102 | says === undefined ? |
| 103 | predicate(data, ctx.external) |
| 104 | : (predicate as Fn)(data, ctx.external, says) |
| 105 | if (label !== undefined) ctx.lbl = outer |
| 106 | if (!valid && ctx.errN === errN) ctx.nodeError(this.errorCtx, data) |
| 107 | } |
| 108 | |
| 109 | compile(js: NodeCompiler): void { |
| 110 | const condition = `${js.ref(this.predicate)}(data, ctx${this.says ? `, ${JSON.stringify(this.says)}` : ""})` |