UNPKG

@thi.ng/pointfree

Version:

Pointfree functional composition / Forth style stack execution engine

19 lines (18 loc) 354 B
import { NO_OP } from "@thi.ng/api/api"; import { illegalState } from "@thi.ng/errors/illegal-state"; let $; let $n; const safeMode = (state) => { if (state) { $n = (m, n) => m < n && illegalState(`stack underflow`); $ = (stack, n) => $n(stack.length, n); } else { $ = $n = NO_OP; } }; safeMode(true); export { $, $n, safeMode };