UNPKG

@jplorg/jpl

Version:
30 lines (29 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _utils = require("./utils"); var _default = exports.default = { /** { pipes: [[op]] } */ op(runtime, input, params, scope, next) { const iter = async from => { // Call stack decoupling - This is necessary as some browsers (i.e. Safari) have very limited call stack sizes which result in stack overflow exceptions in certain situations. await undefined; scope.signal.checkHealth(); if (from >= (params.pipes?.length ?? 0)) return next(true, scope); const pipe = params.pipes[from]; return runtime.executeInstructions(pipe ?? [], [input], scope, output => { if (!runtime.truthy(output)) return next(false, scope); return iter(from + 1); }); }; return iter(0); }, /** { pipes: [function] } */ map(runtime, params) { return { pipes: runtime.muxOne([params.pipes], pipe => (0, _utils.call)(pipe)) }; } };