UNPKG

wonka

Version:

A fast push & pull stream library for Reason, loosely following the [callbag spec](https://github.com/callbag/callbag)

49 lines (43 loc) 1.67 kB
import * as Block from "bs-platform/lib/es6/block.js"; function fromArray(arr) { return (function (sink) { var size = arr.length; var state = /* record */[ /* index */0, /* ended */false, /* looping */false, /* pull */false ]; return sink(/* Start */Block.__(0, [(function (signal) { var match = state[/* looping */2]; if (signal) { state[/* ended */1] = true; return /* () */0; } else if (match) { state[/* pull */3] = true; return /* () */0; } else { state[/* pull */3] = true; state[/* looping */2] = true; while(state[/* pull */3] && !state[/* ended */1]) { var index = state[/* index */0]; if (index < size) { var x = arr[index]; state[/* index */0] = index + 1 | 0; state[/* pull */3] = false; sink(/* Push */Block.__(1, [x])); } else { state[/* ended */1] = true; sink(/* End */0); } }; state[/* looping */2] = false; return /* () */0; } })])); }); } export { fromArray , } /* No side effect */