UNPKG

@basic-streams/ap

Version:
28 lines (27 loc) 714 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function ap(streamF, streamV) { return function (cb) { var latestF = null; var latestV = null; var push = function () { if (latestF && latestV) { var fn = latestF.value; cb(fn(latestV.value)); } }; var disposef = streamF(function (f) { latestF = { value: f }; push(); }); var disposev = streamV(function (v) { latestV = { value: v }; push(); }); return function () { disposef(); disposev(); }; }; } exports.default = ap;