Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wonka

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wonka - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

418

dist/wonka.es.js

@@ -275,3 +275,3 @@ function pipe(source) {

function make$2(f) {
function make(f) {
return function(sink) {

@@ -417,3 +417,3 @@ var teardown = _1(f, [

function map$1(f) {
function map(f) {
return function(source) {

@@ -469,96 +469,283 @@ return function(sink) {

function merge(sources) {
return function(sink) {
var size = sources.length;
var talkbacks = (function make$1(len, vals) {
var res = new Array(len);
res.fill(vals);
return res;
})(size, talkbackPlaceholder);
var state = [0, 0];
var talkback = function(signal) {
var _i = 0;
while (1) {
var i = _i;
if (i < size) {
talkbacks[i](signal);
_i = (i + 1) | 0;
continue;
function mergeMap(f) {
return function(source) {
return function(sink) {
var state = [talkbackPlaceholder, new Array(), !1];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[2]) {
return 0;
} else {
state[2] = !0;
if (0 === state[1].length) {
return sink(0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[2]) {
return 0;
} else {
(innerSource = _1(f, signal[0])),
(talkback = [talkbackPlaceholder]),
_1(innerSource, function(signal) {
if ("number" == typeof signal) {
state[1] = state[1].filter(function(x) {
return x !== talkback[0];
});
if (state[2] && 0 === state[1].length) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
if (0 !== state[1].length) {
sink(__(1, [signal[0]]));
return talkback[0](0);
} else {
return 0;
}
} else {
var tb = signal[0];
talkback[0] = tb;
state[1] = state[1].concat(tb);
return tb(0);
}
});
return state[0](0);
}
} else {
return 0;
var tb = signal[0];
state[0] = tb;
return tb(0);
}
}
};
var _i = 0;
while (1) {
var i = _i;
if (i < size) {
_1(
sources[i],
(function(i) {
return function(signal) {
if ("number" == typeof signal) {
state[1] = (state[1] + 1) | 0;
if (state[1] === size) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
return sink(signal);
var innerSource, talkback;
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[2]) {
return 0;
} else {
talkbacks[i] = signal[0];
state[0] = (state[0] + 1) | 0;
if (state[0] === size) {
return sink(__(0, [talkback]));
} else {
return 0;
}
state[2] = !0;
state[0](1);
state[1].forEach(function(talkback) {
return talkback(1);
});
state[1] = new Array();
return 0;
}
};
})(i)
);
_i = (i + 1) | 0;
continue;
} else {
return 0;
}
}
} else if (state[2]) {
return 0;
} else {
state[1].forEach(function(talkback) {
return talkback(0);
});
return 0;
}
}
])
);
};
};
}
function concat$1(sources) {
return function(sink) {
var size = sources.length;
var talkback = [talkbackPlaceholder];
var nextSource = function(i) {
if (i < size) {
return _1(sources[i], function(signal) {
function merge(sources) {
return mergeMap(function(prim) {
return prim;
})(fromArray(sources));
}
function mergeAll(source) {
return mergeMap(function(prim) {
return prim;
})(source);
}
function concatMap(f) {
return function(source) {
return function(sink) {
var state = [new Array(), talkbackPlaceholder, talkbackPlaceholder, !1, !1, !1];
var applyInnerSource = function(innerSource) {
return _1(innerSource, function(signal) {
if ("number" == typeof signal) {
return nextSource((i + 1) | 0);
state[3] = !1;
state[2] = talkbackPlaceholder;
var match = state[0].shift();
if (void 0 !== match) {
return applyInnerSource(_1(f, valFromOption(match)));
} else if (state[5]) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
return sink(signal);
if (state[4]) {
return 0;
} else {
sink(__(1, [signal[0]]));
return state[2](0);
}
} else {
var tb = signal[0];
talkback[0] = tb;
if (0 === i) {
sink(
__(0, [
function(signal) {
return talkback[0](signal);
}
])
);
}
state[3] = !0;
state[2] = tb;
return tb(0);
}
});
} else {
return sink(0);
}
};
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[5]) {
return 0;
} else {
state[5] = !0;
if (
!state[3] &&
(function isEmpty(q) {
return 0 === q.length;
})(state[0])
) {
return sink(0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[5]) {
return 0;
} else {
var x = signal[0];
if (state[3]) {
state[0].push(x);
} else {
applyInnerSource(_1(f, x));
}
return state[1](0);
}
} else {
var tb = signal[0];
state[1] = tb;
return tb(0);
}
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[5]) {
return 0;
} else {
state[5] = !0;
state[4] = !0;
state[1](1);
return state[2](1);
}
} else if (state[5]) {
return 0;
} else {
return state[2](0);
}
}
])
);
};
return nextSource(0);
};
}
function concatAll(source) {
return concatMap(function(prim) {
return prim;
})(source);
}
function concat(sources) {
return concatMap(function(prim) {
return prim;
})(fromArray(sources));
}
function switchMap(f) {
return function(source) {
return function(sink) {
var state = [talkbackPlaceholder, talkbackPlaceholder, !1, !1, !1];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[4]) {
return 0;
} else {
state[4] = !0;
if (state[2]) {
return 0;
} else {
return sink(0);
}
}
} else if (signal.tag) {
if (state[4]) {
return 0;
} else {
if (state[2]) {
state[1](1);
state[1] = talkbackPlaceholder;
}
(innerSource = _1(f, signal[0])),
_1(innerSource, function(signal) {
if ("number" == typeof signal) {
state[2] = !1;
state[1] = talkbackPlaceholder;
if (state[4]) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[3]) {
return 0;
} else {
sink(__(1, [signal[0]]));
return state[1](0);
}
} else {
var tb = signal[0];
state[2] = !0;
state[1] = tb;
return tb(0);
}
});
return state[0](0);
}
} else {
var tb = signal[0];
state[0] = tb;
return tb(0);
}
var innerSource;
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[4]) {
return 0;
} else {
state[4] = !0;
state[3] = !0;
state[0](1);
state[1](1);
state[1] = talkbackPlaceholder;
return 0;
}
} else {
return state[1](0);
}
}
])
);
};
};
}
function share(source) {

@@ -1007,59 +1194,3 @@ var state = [new Array(), talkbackPlaceholder, !1];

function flatten(source) {
return function(sink) {
var state = [talkbackPlaceholder, talkbackPlaceholder, !1, !0];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[3]) {
return sink(0);
} else {
state[2] = !0;
return 0;
}
} else if (signal.tag) {
return _1(signal[0], function(signal) {
if ("number" == typeof signal) {
if (state[2]) {
return state[0](1);
} else {
state[3] = !0;
return state[0](0);
}
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
if (!state[3]) {
state[1](1);
}
state[3] = !1;
state[1] = tb;
return tb(0);
}
});
} else {
state[0] = signal[0];
return 0;
}
});
return sink(
__(0, [
function(signal) {
if (signal) {
state[0](1);
return state[1](1);
} else if (!state[3] && !state[2]) {
return state[1](0);
} else if (state[2]) {
return 0;
} else {
return state[0](0);
}
}
])
);
};
}
function forEach$1(f) {
function forEach(f) {
return function(source) {

@@ -1112,2 +1243,4 @@ return captureTalkback(source, function(signal, talkback) {

var flatten = mergeAll;
function fromListener(addListener, removeListener) {

@@ -1441,3 +1574,3 @@ return function(sink) {

makeSubject,
make$2 as make,
make,
fromList,

@@ -1449,7 +1582,13 @@ fromArray,

tap,
map$1 as map,
map,
filter,
scan,
mergeMap,
switchMap,
concatMap,
merge,
concat$1 as concat,
concat,
mergeAll,
flatten,
concatAll,
share,

@@ -1464,4 +1603,3 @@ combine,

skipUntil,
flatten,
forEach$1 as forEach,
forEach,
subscribe,

@@ -1468,0 +1606,0 @@ fromListener,

@@ -221,2 +221,222 @@ function __(tag, block) {

function fromArray(arr) {
return function(sink) {
var size = arr.length;
var state = [0, !1, !1, !1];
return sink(
__(0, [
function(signal) {
var match = state[2];
if (signal) {
state[1] = !0;
return 0;
} else if (match) {
state[3] = !0;
return 0;
} else {
state[3] = !0;
state[2] = !0;
while (state[3] && !state[1]) {
var index = state[0];
if (index < size) {
var x = arr[index];
state[0] = (index + 1) | 0;
state[3] = !1;
sink(__(1, [x]));
} else {
state[1] = !0;
sink(0);
}
}
state[2] = !1;
return 0;
}
}
])
);
};
}
function mergeMap(f) {
return function(source) {
return function(sink) {
var state = [talkbackPlaceholder, new Array(), !1];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[2]) {
return 0;
} else {
state[2] = !0;
if (0 === state[1].length) {
return sink(0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[2]) {
return 0;
} else {
(innerSource = _1(f, signal[0])),
(talkback = [talkbackPlaceholder]),
_1(innerSource, function(signal) {
if ("number" == typeof signal) {
state[1] = state[1].filter(function(x) {
return x !== talkback[0];
});
if (state[2] && 0 === state[1].length) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
if (0 !== state[1].length) {
sink(__(1, [signal[0]]));
return talkback[0](0);
} else {
return 0;
}
} else {
var tb = signal[0];
talkback[0] = tb;
state[1] = state[1].concat(tb);
return tb(0);
}
});
return state[0](0);
}
} else {
var tb = signal[0];
state[0] = tb;
return tb(0);
}
var innerSource, talkback;
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[2]) {
return 0;
} else {
state[2] = !0;
state[0](1);
state[1].forEach(function(talkback) {
return talkback(1);
});
state[1] = new Array();
return 0;
}
} else if (state[2]) {
return 0;
} else {
state[1].forEach(function(talkback) {
return talkback(0);
});
return 0;
}
}
])
);
};
};
}
function mergeAll(source) {
return mergeMap(function(prim) {
return prim;
})(source);
}
function concatMap(f) {
return function(source) {
return function(sink) {
var state = [new Array(), talkbackPlaceholder, talkbackPlaceholder, !1, !1, !1];
var applyInnerSource = function(innerSource) {
return _1(innerSource, function(signal) {
if ("number" == typeof signal) {
state[3] = !1;
state[2] = talkbackPlaceholder;
var match = state[0].shift();
if (void 0 !== match) {
return applyInnerSource(_1(f, valFromOption(match)));
} else if (state[5]) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[4]) {
return 0;
} else {
sink(__(1, [signal[0]]));
return state[2](0);
}
} else {
var tb = signal[0];
state[3] = !0;
state[2] = tb;
return tb(0);
}
});
};
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[5]) {
return 0;
} else {
state[5] = !0;
if (
!state[3] &&
(function isEmpty(q) {
return 0 === q.length;
})(state[0])
) {
return sink(0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[5]) {
return 0;
} else {
var x = signal[0];
if (state[3]) {
state[0].push(x);
} else {
applyInnerSource(_1(f, x));
}
return state[1](0);
}
} else {
var tb = signal[0];
state[1] = tb;
return tb(0);
}
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[5]) {
return 0;
} else {
state[5] = !0;
state[4] = !0;
state[1](1);
return state[2](1);
}
} else if (state[5]) {
return 0;
} else {
return state[2](0);
}
}
])
);
};
};
}
function takeLast(max) {

@@ -283,2 +503,4 @@ return function(source) {

var flatten = mergeAll;
function fromListener(addListener, removeListener) {

@@ -360,3 +582,3 @@ return function(sink) {

exports.make = function make$2(f) {
exports.make = function make(f) {
return function(sink) {

@@ -421,39 +643,3 @@ var teardown = _1(f, [

exports.fromArray = function fromArray(arr) {
return function(sink) {
var size = arr.length;
var state = [0, !1, !1, !1];
return sink(
__(0, [
function(signal) {
var match = state[2];
if (signal) {
state[1] = !0;
return 0;
} else if (match) {
state[3] = !0;
return 0;
} else {
state[3] = !0;
state[2] = !0;
while (state[3] && !state[1]) {
var index = state[0];
if (index < size) {
var x = arr[index];
state[0] = (index + 1) | 0;
state[3] = !1;
sink(__(1, [x]));
} else {
state[1] = !0;
sink(0);
}
}
state[2] = !1;
return 0;
}
}
])
);
};
};
exports.fromArray = fromArray;

@@ -503,3 +689,3 @@ exports.fromValue = function fromValue(x) {

exports.map = function map$1(f) {
exports.map = function map(f) {
return function(source) {

@@ -555,96 +741,109 @@ return function(sink) {

exports.merge = function merge(sources) {
return function(sink) {
var size = sources.length;
var talkbacks = (function make$1(len, vals) {
var res = new Array(len);
res.fill(vals);
return res;
})(size, talkbackPlaceholder);
var state = [0, 0];
var talkback = function(signal) {
var _i = 0;
while (1) {
var i = _i;
if (i < size) {
talkbacks[i](signal);
_i = (i + 1) | 0;
continue;
exports.mergeMap = mergeMap;
exports.switchMap = function switchMap(f) {
return function(source) {
return function(sink) {
var state = [talkbackPlaceholder, talkbackPlaceholder, !1, !1, !1];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[4]) {
return 0;
} else {
state[4] = !0;
if (state[2]) {
return 0;
} else {
return sink(0);
}
}
} else if (signal.tag) {
if (state[4]) {
return 0;
} else {
if (state[2]) {
state[1](1);
state[1] = talkbackPlaceholder;
}
(innerSource = _1(f, signal[0])),
_1(innerSource, function(signal) {
if ("number" == typeof signal) {
state[2] = !1;
state[1] = talkbackPlaceholder;
if (state[4]) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[3]) {
return 0;
} else {
sink(__(1, [signal[0]]));
return state[1](0);
}
} else {
var tb = signal[0];
state[2] = !0;
state[1] = tb;
return tb(0);
}
});
return state[0](0);
}
} else {
return 0;
var tb = signal[0];
state[0] = tb;
return tb(0);
}
}
};
var _i = 0;
while (1) {
var i = _i;
if (i < size) {
_1(
sources[i],
(function(i) {
return function(signal) {
if ("number" == typeof signal) {
state[1] = (state[1] + 1) | 0;
if (state[1] === size) {
return sink(0);
} else {
return 0;
}
} else if (signal.tag) {
return sink(signal);
var innerSource;
});
return sink(
__(0, [
function(signal) {
if (signal) {
if (state[4]) {
return 0;
} else {
talkbacks[i] = signal[0];
state[0] = (state[0] + 1) | 0;
if (state[0] === size) {
return sink(__(0, [talkback]));
} else {
return 0;
}
state[4] = !0;
state[3] = !0;
state[0](1);
state[1](1);
state[1] = talkbackPlaceholder;
return 0;
}
};
})(i)
);
_i = (i + 1) | 0;
continue;
} else {
return 0;
}
}
};
};
exports.concat = function concat$1(sources) {
return function(sink) {
var size = sources.length;
var talkback = [talkbackPlaceholder];
var nextSource = function(i) {
if (i < size) {
return _1(sources[i], function(signal) {
if ("number" == typeof signal) {
return nextSource((i + 1) | 0);
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
talkback[0] = tb;
if (0 === i) {
sink(
__(0, [
function(signal) {
return talkback[0](signal);
}
])
);
} else {
return state[1](0);
}
return tb(0);
}
});
} else {
return sink(0);
}
])
);
};
return nextSource(0);
};
};
exports.concatMap = concatMap;
exports.merge = function merge(sources) {
return mergeMap(function(prim) {
return prim;
})(fromArray(sources));
};
exports.concat = function concat(sources) {
return concatMap(function(prim) {
return prim;
})(fromArray(sources));
};
exports.mergeAll = mergeAll;
exports.flatten = flatten;
exports.concatAll = function concatAll(source) {
return concatMap(function(prim) {
return prim;
})(source);
};
exports.share = function share(source) {

@@ -1034,59 +1233,3 @@ var state = [new Array(), talkbackPlaceholder, !1];

exports.flatten = function flatten(source) {
return function(sink) {
var state = [talkbackPlaceholder, talkbackPlaceholder, !1, !0];
_1(source, function(signal) {
if ("number" == typeof signal) {
if (state[3]) {
return sink(0);
} else {
state[2] = !0;
return 0;
}
} else if (signal.tag) {
return _1(signal[0], function(signal) {
if ("number" == typeof signal) {
if (state[2]) {
return state[0](1);
} else {
state[3] = !0;
return state[0](0);
}
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
if (!state[3]) {
state[1](1);
}
state[3] = !1;
state[1] = tb;
return tb(0);
}
});
} else {
state[0] = signal[0];
return 0;
}
});
return sink(
__(0, [
function(signal) {
if (signal) {
state[0](1);
return state[1](1);
} else if (!state[3] && !state[2]) {
return state[1](0);
} else if (state[2]) {
return 0;
} else {
return state[0](0);
}
}
])
);
};
};
exports.forEach = function forEach$1(f) {
exports.forEach = function forEach(f) {
return function(source) {

@@ -1093,0 +1236,0 @@ return captureTalkback(source, function(signal, talkback) {

@@ -5,5 +5,5 @@ 'use strict';

var Curry = require("bs-platform/lib/js/curry.js");
var Array_js = require("bs-rebel/lib/js/src/js/Array_js.js");
var Caml_option = require("bs-platform/lib/js/caml_option.js");
var Wonka_helpers = require("./wonka_helpers.js");
var MutableQueue_js = require("bs-rebel/lib/js/src/js/MutableQueue_js.js");

@@ -240,87 +240,282 @@ function makeSubject(param) {

function merge(sources) {
return (function (sink) {
var size = sources.length;
var talkbacks = Array_js.make(size, Wonka_helpers.talkbackPlaceholder);
var state = /* record */[
/* started */0,
/* ended */0
];
var talkback = function (signal) {
var _i = 0;
while(true) {
var i = _i;
if (i < size) {
talkbacks[i](signal);
_i = i + 1 | 0;
continue ;
} else {
return 0;
}
};
};
var _i = 0;
while(true) {
var i = _i;
if (i < size) {
var source = sources[i];
Curry._1(source, (function(i){
return function (signal) {
if (typeof signal === "number") {
state[/* ended */1] = state[/* ended */1] + 1 | 0;
if (state[/* ended */1] === size) {
return sink(/* End */0);
function mergeMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkbacks */new Array(),
/* ended */false
];
var applyInnerSource = function (innerSource) {
var talkback = /* record */[/* contents */Wonka_helpers.talkbackPlaceholder];
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerTalkbacks */1] = state[/* innerTalkbacks */1].filter((function (x) {
return x !== talkback[0];
}));
if (state[/* ended */2] && state[/* innerTalkbacks */1].length === 0) {
return sink(/* End */0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[/* innerTalkbacks */1].length !== 0) {
sink(/* Push */Block.__(1, [signal[0]]));
return talkback[0](/* Pull */0);
} else {
return /* () */0;
}
} else {
var tb = signal[0];
talkback[0] = tb;
state[/* innerTalkbacks */1] = state[/* innerTalkbacks */1].concat(tb);
return tb(/* Pull */0);
}
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* ended */2] = true;
if (state[/* innerTalkbacks */1].length === 0) {
return sink(/* End */0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[/* ended */2]) {
return /* () */0;
} else {
applyInnerSource(Curry._1(f, signal[0]));
return state[/* outerTalkback */0](/* Pull */0);
}
} else {
return 0;
var tb = signal[0];
state[/* outerTalkback */0] = tb;
return tb(/* Pull */0);
}
} else if (signal.tag) {
return sink(signal);
} else {
talkbacks[i] = signal[0];
state[/* started */0] = state[/* started */0] + 1 | 0;
if (state[/* started */0] === size) {
return sink(/* Start */Block.__(0, [talkback]));
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* ended */2] = true;
state[/* outerTalkback */0](/* Close */1);
state[/* innerTalkbacks */1].forEach((function (talkback) {
return talkback(/* Close */1);
}));
state[/* innerTalkbacks */1] = new Array();
return /* () */0;
}
} else if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* innerTalkbacks */1].forEach((function (talkback) {
return talkback(/* Pull */0);
}));
return /* () */0;
}
})]));
});
});
}
function merge(sources) {
return mergeMap((function (prim) {
return prim;
}))(fromArray(sources));
}
function mergeAll(source) {
return mergeMap((function (prim) {
return prim;
}))(source);
}
function concatMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* inputQueue */new Array(),
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerActive */false,
/* closed */false,
/* ended */false
];
var applyInnerSource = function (innerSource) {
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerActive */3] = false;
state[/* innerTalkback */2] = Wonka_helpers.talkbackPlaceholder;
var match = state[/* inputQueue */0].shift();
if (match !== undefined) {
return applyInnerSource(Curry._1(f, Caml_option.valFromOption(match)));
} else if (state[/* ended */5]) {
return sink(/* End */0);
} else {
return /* () */0;
}
} else if (signal.tag) {
if (state[/* closed */4]) {
return /* () */0;
} else {
sink(/* Push */Block.__(1, [signal[0]]));
return state[/* innerTalkback */2](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* innerActive */3] = true;
state[/* innerTalkback */2] = tb;
return tb(/* Pull */0);
}
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */5]) {
return /* () */0;
} else {
state[/* ended */5] = true;
if (!state[/* innerActive */3] && MutableQueue_js.isEmpty(state[/* inputQueue */0])) {
return sink(/* End */0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[/* ended */5]) {
return /* () */0;
} else {
var x = signal[0];
if (state[/* innerActive */3]) {
state[/* inputQueue */0].push(x);
} else {
applyInnerSource(Curry._1(f, x));
}
return state[/* outerTalkback */1](/* Pull */0);
}
} else {
return 0;
var tb = signal[0];
state[/* outerTalkback */1] = tb;
return tb(/* Pull */0);
}
}
}
}(i)));
_i = i + 1 | 0;
continue ;
} else {
return 0;
}
};
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */5]) {
return /* () */0;
} else {
state[/* ended */5] = true;
state[/* closed */4] = true;
state[/* outerTalkback */1](/* Close */1);
return state[/* innerTalkback */2](/* Close */1);
}
} else if (state[/* ended */5]) {
return 0;
} else {
return state[/* innerTalkback */2](/* Pull */0);
}
})]));
});
});
}
function concatAll(source) {
return concatMap((function (prim) {
return prim;
}))(source);
}
function concat(sources) {
return (function (sink) {
var size = sources.length;
var talkback = /* record */[/* contents */Wonka_helpers.talkbackPlaceholder];
var nextSource = function (i) {
if (i < size) {
var source = sources[i];
return Curry._1(source, (function (signal) {
if (typeof signal === "number") {
return nextSource(i + 1 | 0);
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
talkback[0] = tb;
if (i === 0) {
sink(/* Start */Block.__(0, [(function (signal) {
return talkback[0](signal);
})]));
return concatMap((function (prim) {
return prim;
}))(fromArray(sources));
}
function switchMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerActive */false,
/* closed */false,
/* ended */false
];
var applyInnerSource = function (innerSource) {
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerActive */2] = false;
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
if (state[/* ended */4]) {
return sink(/* End */0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[/* closed */3]) {
return /* () */0;
} else {
sink(/* Push */Block.__(1, [signal[0]]));
return state[/* innerTalkback */1](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* innerActive */2] = true;
state[/* innerTalkback */1] = tb;
return tb(/* Pull */0);
}
return tb(/* Pull */0);
}
}));
} else {
return sink(/* End */0);
}
};
return nextSource(0);
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */4]) {
return /* () */0;
} else {
state[/* ended */4] = true;
if (state[/* innerActive */2]) {
return 0;
} else {
return sink(/* End */0);
}
}
} else if (signal.tag) {
if (state[/* ended */4]) {
return /* () */0;
} else {
if (state[/* innerActive */2]) {
state[/* innerTalkback */1](/* Close */1);
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
}
applyInnerSource(Curry._1(f, signal[0]));
return state[/* outerTalkback */0](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* outerTalkback */0] = tb;
return tb(/* Pull */0);
}
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */4]) {
return /* () */0;
} else {
state[/* ended */4] = true;
state[/* closed */3] = true;
state[/* outerTalkback */0](/* Close */1);
state[/* innerTalkback */1](/* Close */1);
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
return /* () */0;
}
} else {
return state[/* innerTalkback */1](/* Pull */0);
}
})]));
});
});

@@ -742,60 +937,2 @@ }

function flatten(source) {
return (function (sink) {
var state = /* record */[
/* sourceTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* sourceEnded */false,
/* innerEnded */true
];
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* innerEnded */3]) {
return sink(/* End */0);
} else {
state[/* sourceEnded */2] = true;
return /* () */0;
}
} else if (signal.tag) {
var innerSource = signal[0];
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
if (state[/* sourceEnded */2]) {
return state[/* sourceTalkback */0](/* Close */1);
} else {
state[/* innerEnded */3] = true;
return state[/* sourceTalkback */0](/* Pull */0);
}
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
if (!state[/* innerEnded */3]) {
state[/* innerTalkback */1](/* Close */1);
}
state[/* innerEnded */3] = false;
state[/* innerTalkback */1] = tb;
return tb(/* Pull */0);
}
}));
} else {
state[/* sourceTalkback */0] = signal[0];
return /* () */0;
}
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
state[/* sourceTalkback */0](/* Close */1);
return state[/* innerTalkback */1](/* Close */1);
} else if (!state[/* innerEnded */3] && !state[/* sourceEnded */2]) {
return state[/* innerTalkback */1](/* Pull */0);
} else if (state[/* sourceEnded */2]) {
return /* () */0;
} else {
return state[/* sourceTalkback */0](/* Pull */0);
}
})]));
});
}
function forEach(f) {

@@ -849,2 +986,4 @@ return (function (source) {

var flatten = mergeAll;
exports.Types = Types;

@@ -862,4 +1001,10 @@ exports.makeSubject = makeSubject;

exports.scan = scan;
exports.mergeMap = mergeMap;
exports.switchMap = switchMap;
exports.concatMap = concatMap;
exports.merge = merge;
exports.concat = concat;
exports.mergeAll = mergeAll;
exports.flatten = flatten;
exports.concatAll = concatAll;
exports.share = share;

@@ -874,5 +1019,4 @@ exports.combine = combine;

exports.skipUntil = skipUntil;
exports.flatten = flatten;
exports.forEach = forEach;
exports.subscribe = subscribe;
/* No side effect */
{
"name": "wonka",
"version": "1.2.0",
"version": "1.3.0",
"author": "Phil Pluckthun <phil@kitten.sh>",

@@ -5,0 +5,0 @@ "source": "./src/index.js",

@@ -16,2 +16,6 @@ import { List, Sink, Source, Operator, Observer, Subject } from './wonka_types';

export const mergeMap: <A, B>(f: (value: A) => Source<B>) => Operator<A, B>;
export const switchMap: <A, B>(f: (value: A) => Source<B>) => Operator<A, B>;
export const concatMap: <A, B>(f: (value: A) => Source<B>) => Operator<A, B>;
export const merge: <A>(sources: Array<Source<A>>) => Source<A>;

@@ -22,2 +26,6 @@ export const concat: <A>(sources: Array<Source<A>>) => Source<A>;

export const concatAll: <A>(source: Source<Source<A>>) => Source<A>;
export const mergeAll: <A>(source: Source<Source<A>>) => Source<A>;
export const flatten: <A>(source: Source<Source<A>>) => Source<A>;
export const take: <A>(max: number) => Operator<A, A>;

@@ -31,5 +39,3 @@ export const takeLast: <A>(max: number) => Operator<A, A>;

export const flatten: <A>(source: Source<Source<A>>) => Source<A>;
export const forEach: <A>(f: (x: A) => void) => (source: Source<A>) => void;
export const subscribe: <A>(f: (x: A) => void) => (source: Source<A>) => (() => void);

@@ -5,5 +5,5 @@

import * as Curry from "bs-platform/lib/es6/curry.js";
import * as Array_js from "bs-rebel/src/js/Array_js.js";
import * as Caml_option from "bs-platform/lib/es6/caml_option.js";
import * as Wonka_helpers from "./wonka_helpers.js";
import * as MutableQueue_js from "bs-rebel/src/js/MutableQueue_js.js";

@@ -240,87 +240,282 @@ function makeSubject(param) {

function merge(sources) {
return (function (sink) {
var size = sources.length;
var talkbacks = Array_js.make(size, Wonka_helpers.talkbackPlaceholder);
var state = /* record */[
/* started */0,
/* ended */0
];
var talkback = function (signal) {
var _i = 0;
while(true) {
var i = _i;
if (i < size) {
talkbacks[i](signal);
_i = i + 1 | 0;
continue ;
} else {
return 0;
}
};
};
var _i = 0;
while(true) {
var i = _i;
if (i < size) {
var source = sources[i];
Curry._1(source, (function(i){
return function (signal) {
if (typeof signal === "number") {
state[/* ended */1] = state[/* ended */1] + 1 | 0;
if (state[/* ended */1] === size) {
return sink(/* End */0);
function mergeMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkbacks */new Array(),
/* ended */false
];
var applyInnerSource = function (innerSource) {
var talkback = /* record */[/* contents */Wonka_helpers.talkbackPlaceholder];
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerTalkbacks */1] = state[/* innerTalkbacks */1].filter((function (x) {
return x !== talkback[0];
}));
if (state[/* ended */2] && state[/* innerTalkbacks */1].length === 0) {
return sink(/* End */0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[/* innerTalkbacks */1].length !== 0) {
sink(/* Push */Block.__(1, [signal[0]]));
return talkback[0](/* Pull */0);
} else {
return /* () */0;
}
} else {
var tb = signal[0];
talkback[0] = tb;
state[/* innerTalkbacks */1] = state[/* innerTalkbacks */1].concat(tb);
return tb(/* Pull */0);
}
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* ended */2] = true;
if (state[/* innerTalkbacks */1].length === 0) {
return sink(/* End */0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[/* ended */2]) {
return /* () */0;
} else {
applyInnerSource(Curry._1(f, signal[0]));
return state[/* outerTalkback */0](/* Pull */0);
}
} else {
return 0;
var tb = signal[0];
state[/* outerTalkback */0] = tb;
return tb(/* Pull */0);
}
} else if (signal.tag) {
return sink(signal);
} else {
talkbacks[i] = signal[0];
state[/* started */0] = state[/* started */0] + 1 | 0;
if (state[/* started */0] === size) {
return sink(/* Start */Block.__(0, [talkback]));
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* ended */2] = true;
state[/* outerTalkback */0](/* Close */1);
state[/* innerTalkbacks */1].forEach((function (talkback) {
return talkback(/* Close */1);
}));
state[/* innerTalkbacks */1] = new Array();
return /* () */0;
}
} else if (state[/* ended */2]) {
return /* () */0;
} else {
state[/* innerTalkbacks */1].forEach((function (talkback) {
return talkback(/* Pull */0);
}));
return /* () */0;
}
})]));
});
});
}
function merge(sources) {
return mergeMap((function (prim) {
return prim;
}))(fromArray(sources));
}
function mergeAll(source) {
return mergeMap((function (prim) {
return prim;
}))(source);
}
function concatMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* inputQueue */new Array(),
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerActive */false,
/* closed */false,
/* ended */false
];
var applyInnerSource = function (innerSource) {
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerActive */3] = false;
state[/* innerTalkback */2] = Wonka_helpers.talkbackPlaceholder;
var match = state[/* inputQueue */0].shift();
if (match !== undefined) {
return applyInnerSource(Curry._1(f, Caml_option.valFromOption(match)));
} else if (state[/* ended */5]) {
return sink(/* End */0);
} else {
return /* () */0;
}
} else if (signal.tag) {
if (state[/* closed */4]) {
return /* () */0;
} else {
sink(/* Push */Block.__(1, [signal[0]]));
return state[/* innerTalkback */2](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* innerActive */3] = true;
state[/* innerTalkback */2] = tb;
return tb(/* Pull */0);
}
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */5]) {
return /* () */0;
} else {
state[/* ended */5] = true;
if (!state[/* innerActive */3] && MutableQueue_js.isEmpty(state[/* inputQueue */0])) {
return sink(/* End */0);
} else {
return 0;
}
}
} else if (signal.tag) {
if (state[/* ended */5]) {
return /* () */0;
} else {
var x = signal[0];
if (state[/* innerActive */3]) {
state[/* inputQueue */0].push(x);
} else {
applyInnerSource(Curry._1(f, x));
}
return state[/* outerTalkback */1](/* Pull */0);
}
} else {
return 0;
var tb = signal[0];
state[/* outerTalkback */1] = tb;
return tb(/* Pull */0);
}
}
}
}(i)));
_i = i + 1 | 0;
continue ;
} else {
return 0;
}
};
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */5]) {
return /* () */0;
} else {
state[/* ended */5] = true;
state[/* closed */4] = true;
state[/* outerTalkback */1](/* Close */1);
return state[/* innerTalkback */2](/* Close */1);
}
} else if (state[/* ended */5]) {
return 0;
} else {
return state[/* innerTalkback */2](/* Pull */0);
}
})]));
});
});
}
function concatAll(source) {
return concatMap((function (prim) {
return prim;
}))(source);
}
function concat(sources) {
return (function (sink) {
var size = sources.length;
var talkback = /* record */[/* contents */Wonka_helpers.talkbackPlaceholder];
var nextSource = function (i) {
if (i < size) {
var source = sources[i];
return Curry._1(source, (function (signal) {
if (typeof signal === "number") {
return nextSource(i + 1 | 0);
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
talkback[0] = tb;
if (i === 0) {
sink(/* Start */Block.__(0, [(function (signal) {
return talkback[0](signal);
})]));
return concatMap((function (prim) {
return prim;
}))(fromArray(sources));
}
function switchMap(f) {
return (function (source) {
return (function (sink) {
var state = /* record */[
/* outerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerActive */false,
/* closed */false,
/* ended */false
];
var applyInnerSource = function (innerSource) {
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
state[/* innerActive */2] = false;
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
if (state[/* ended */4]) {
return sink(/* End */0);
} else {
return 0;
}
} else if (signal.tag) {
if (state[/* closed */3]) {
return /* () */0;
} else {
sink(/* Push */Block.__(1, [signal[0]]));
return state[/* innerTalkback */1](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* innerActive */2] = true;
state[/* innerTalkback */1] = tb;
return tb(/* Pull */0);
}
return tb(/* Pull */0);
}
}));
} else {
return sink(/* End */0);
}
};
return nextSource(0);
}));
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* ended */4]) {
return /* () */0;
} else {
state[/* ended */4] = true;
if (state[/* innerActive */2]) {
return 0;
} else {
return sink(/* End */0);
}
}
} else if (signal.tag) {
if (state[/* ended */4]) {
return /* () */0;
} else {
if (state[/* innerActive */2]) {
state[/* innerTalkback */1](/* Close */1);
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
}
applyInnerSource(Curry._1(f, signal[0]));
return state[/* outerTalkback */0](/* Pull */0);
}
} else {
var tb = signal[0];
state[/* outerTalkback */0] = tb;
return tb(/* Pull */0);
}
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
if (state[/* ended */4]) {
return /* () */0;
} else {
state[/* ended */4] = true;
state[/* closed */3] = true;
state[/* outerTalkback */0](/* Close */1);
state[/* innerTalkback */1](/* Close */1);
state[/* innerTalkback */1] = Wonka_helpers.talkbackPlaceholder;
return /* () */0;
}
} else {
return state[/* innerTalkback */1](/* Pull */0);
}
})]));
});
});

@@ -742,60 +937,2 @@ }

function flatten(source) {
return (function (sink) {
var state = /* record */[
/* sourceTalkback */Wonka_helpers.talkbackPlaceholder,
/* innerTalkback */Wonka_helpers.talkbackPlaceholder,
/* sourceEnded */false,
/* innerEnded */true
];
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state[/* innerEnded */3]) {
return sink(/* End */0);
} else {
state[/* sourceEnded */2] = true;
return /* () */0;
}
} else if (signal.tag) {
var innerSource = signal[0];
return Curry._1(innerSource, (function (signal) {
if (typeof signal === "number") {
if (state[/* sourceEnded */2]) {
return state[/* sourceTalkback */0](/* Close */1);
} else {
state[/* innerEnded */3] = true;
return state[/* sourceTalkback */0](/* Pull */0);
}
} else if (signal.tag) {
return sink(signal);
} else {
var tb = signal[0];
if (!state[/* innerEnded */3]) {
state[/* innerTalkback */1](/* Close */1);
}
state[/* innerEnded */3] = false;
state[/* innerTalkback */1] = tb;
return tb(/* Pull */0);
}
}));
} else {
state[/* sourceTalkback */0] = signal[0];
return /* () */0;
}
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
state[/* sourceTalkback */0](/* Close */1);
return state[/* innerTalkback */1](/* Close */1);
} else if (!state[/* innerEnded */3] && !state[/* sourceEnded */2]) {
return state[/* innerTalkback */1](/* Pull */0);
} else if (state[/* sourceEnded */2]) {
return /* () */0;
} else {
return state[/* sourceTalkback */0](/* Pull */0);
}
})]));
});
}
function forEach(f) {

@@ -849,2 +986,4 @@ return (function (source) {

var flatten = mergeAll;
export {

@@ -863,4 +1002,10 @@ Types ,

scan ,
mergeMap ,
switchMap ,
concatMap ,
merge ,
concat ,
mergeAll ,
flatten ,
concatAll ,
share ,

@@ -875,3 +1020,2 @@ combine ,

skipUntil ,
flatten ,
forEach ,

@@ -878,0 +1022,0 @@ subscribe ,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc