wonka
Version:
A fast push & pull stream library for Reason, loosely following the [callbag spec](https://github.com/callbag/callbag)
44 lines (40 loc) • 1.6 kB
JavaScript
;
var Block = require("bs-platform/lib/js/block.js");
function fromList(ls) {
return (function (sink) {
var state = /* record */[
/* value */ls,
/* 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 match$1 = state[/* value */0];
if (match$1) {
state[/* value */0] = match$1[1];
state[/* pull */3] = false;
sink(/* Push */Block.__(1, [match$1[0]]));
} else {
state[/* ended */1] = true;
sink(/* End */0);
}
};
state[/* looping */2] = false;
return /* () */0;
}
})]));
});
}
exports.fromList = fromList;
/* No side effect */