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 0.0.0-canary-20230321073435 to 0.0.0-canary-20230326035503

src/types.d.ts

4

CHANGELOG.md
# wonka
## 0.0.0-canary-20230321073435
## 0.0.0-canary-20230326035503

@@ -9,2 +9,4 @@ ### Patch Changes

Submitted by [@kitten](https://github.com/kitten) (See [`56d9708`](https://github.com/0no-co/wonka/commit/56d970861424fddd403262bf85d7e1e3572b15e2))
- ⚠️ Fix internal `SignalKind` and `TalkbackKind` enums not compiling away
Submitted by [@kitten](https://github.com/kitten) (See [#154](https://github.com/0no-co/wonka/pull/154))

@@ -11,0 +13,0 @@ ## 6.2.5

@@ -9,8 +9,9 @@ /**

*/
declare const enum TalkbackKind {
/** Instructs the {@link Source} to send the next value. */
Pull = 0,
/** Instructs the {@link Source} to stop sending values and cancels it. */
Close = 1
enum TalkbackKind {
/** Instructs the {@link Source} to send the next value. */
Pull = 0,
/** Instructs the {@link Source} to stop sending values and cancels it. */
Close = 1,
}
/**

@@ -24,2 +25,3 @@ * Talkback callback that sends instructions to a source.

type TalkbackFn = (signal: TalkbackKind) => void;
/**

@@ -33,2 +35,3 @@ * Callback that is called when a source is cancelled.

type TeardownFn = () => void;
/**

@@ -44,30 +47,31 @@ * Tag enum that is used to on signals that are sent from a source to a sink.

*/
declare const enum SignalKind {
/**
* Informs the {@link Sink} that it's being called by a {@link Source}.
*
* @remarks
* This starts the stream of values and carries a {@link TalkbackFn | talkback function} with it
* that is used by the {@link Sink} to communicate back to the {@link Source}.
* @see {@link Start} for the data structure of the signal.
*/
Start = 0,
/**
* Informs the {@link Sink} of a new values that's incoming from the {@link Source}.
*
* @remarks
* This informs the {@link Sink} of new values that are sent by the {@link Source}.
* @see {@link Push} for the data structure of the signal.
*/
Push = 1,
/**
* Informs the {@link Sink} that the {@link Source} has ended and that it won't send more values.
*
* @remarks
* This signal signifies that the stream has stopped and that no more values are expected. Some
* sources don't have a set end or limit on how many values will be sent. This signal is not sent
* when the {@link Source} is cancelled with a {@link TalkbackKind.Close | Close talkback signal}.
*/
End = 0
enum SignalKind {
/**
* Informs the {@link Sink} that it's being called by a {@link Source}.
*
* @remarks
* This starts the stream of values and carries a {@link TalkbackFn | talkback function} with it
* that is used by the {@link Sink} to communicate back to the {@link Source}.
* @see {@link Start} for the data structure of the signal.
*/
Start = 0,
/**
* Informs the {@link Sink} of a new values that's incoming from the {@link Source}.
*
* @remarks
* This informs the {@link Sink} of new values that are sent by the {@link Source}.
* @see {@link Push} for the data structure of the signal.
*/
Push = 1,
/**
* Informs the {@link Sink} that the {@link Source} has ended and that it won't send more values.
*
* @remarks
* This signal signifies that the stream has stopped and that no more values are expected. Some
* sources don't have a set end or limit on how many values will be sent. This signal is not sent
* when the {@link Source} is cancelled with a {@link TalkbackKind.Close | Close talkback signal}.
*/
End = 0,
}
/**

@@ -79,4 +83,5 @@ * The tag property that's put on unary `[T]` tuple to turn them into signals carrying values.

interface Tag<T> {
tag: T;
tag: T;
}
/**

@@ -93,2 +98,3 @@ * Indicates the start of a stream to a {@link Sink}.

type Start<_T> = Tag<SignalKind.Start> & [TalkbackFn];
/**

@@ -103,2 +109,3 @@ * Sends a new value to a {@link Sink}.

type Push<T> = Tag<SignalKind.Push> & [T];
/**

@@ -119,2 +126,3 @@ * Signals are sent from {@link Source | Sources} to {@link Sink | Sinks} to inform them of changes.

type Signal<T> = Start<T> | Push<T> | SignalKind.End;
/**

@@ -129,2 +137,3 @@ * Callback function that is called by a {@link Source} with {@link Signal | Signals}.

type Sink<T> = (signal: Signal<T>) => void;
/** Factory function that calls {@link Sink | Sinks} with {@link Signal | Signals} when invoked.

@@ -142,2 +151,3 @@ * @remarks

type Source<T> = (sink: Sink<T>) => void;
/** Transform function that accepts a {@link Source} and returns a new one.

@@ -152,4 +162,6 @@ * @remarks

type Operator<In, Out> = (a: Source<In>) => Source<Out>;
/** Type utility to determine the type of a {@link Source}. */
type TypeOfSource<T> = T extends Source<infer U> ? U : never;
/** Subscription object that can be used to cancel a {@link Source}.

@@ -159,11 +171,12 @@ * @see {@link subscribe | subscribe sink} for a helper that returns this structure.

interface Subscription {
/**
* Cancels a {@link Source} to stop the subscription from receiving new values.
*
* @see {@link TalkbackKind.Close | Close signal} This uses the {@link TalkbackFn | talkback function} to send a {@link TalkbackKind.Close | Close signal}
* to the subscribed-to {@link Source} to stop it from sending new values. This cleans up the subscription
* and ends it immediately.
*/
unsubscribe(): void;
/**
* Cancels a {@link Source} to stop the subscription from receiving new values.
*
* @see {@link TalkbackKind.Close | Close signal} This uses the {@link TalkbackFn | talkback function} to send a {@link TalkbackKind.Close | Close signal}
* to the subscribed-to {@link Source} to stop it from sending new values. This cleans up the subscription
* and ends it immediately.
*/
unsubscribe(): void;
}
/** An Observer represents sending signals manually to a {@link Sink}.

@@ -177,15 +190,16 @@ * @remarks

interface Observer<T> {
/** Sends a new value to the receiving Sink.
* @remarks
* This creates a {@link Push | Push signal} that is sent to a {@link Sink}.
*/
next(value: T): void;
/** Indicates to the receiving Sink that no more values will be sent.
* @remarks
* This creates an {@link SignalKind.End | End signal} that is sent to a {@link Sink}. The Observer
* will accept no more values via {@link Observer.next | `next` calls} once this method has been
* invoked.
*/
complete(): void;
/** Sends a new value to the receiving Sink.
* @remarks
* This creates a {@link Push | Push signal} that is sent to a {@link Sink}.
*/
next(value: T): void;
/** Indicates to the receiving Sink that no more values will be sent.
* @remarks
* This creates an {@link SignalKind.End | End signal} that is sent to a {@link Sink}. The Observer
* will accept no more values via {@link Observer.next | `next` calls} once this method has been
* invoked.
*/
complete(): void;
}
/** Subjects combine a {@link Source} with the {@link Observer} that is used to send values on said Source.

@@ -199,4 +213,4 @@ * @remarks

interface Subject<T> extends Observer<T> {
/** The {@link Source} that issues the signals as the {@link Observer} methods are called. */
source: Source<T>;
/** The {@link Source} that issues the signals as the {@link Observer} methods are called. */
source: Source<T>;
}

@@ -203,0 +217,0 @@

@@ -5,31 +5,16 @@ Object.defineProperty(exports, "__esModule", {

var e;
!function(e) {
e[e.Pull = 0] = "Pull";
e[e.Close = 1] = "Close";
}(e || (e = {}));
var r;
!function(e) {
e[e.Start = 0] = "Start";
e[e.Push = 1] = "Push";
e[e.End = 0] = "End";
}(r || (r = {}));
var teardownPlaceholder = () => {};
var t = teardownPlaceholder;
var e = teardownPlaceholder;
function start(e) {
var t = [ e ];
t.tag = r.Start;
return t;
var r = [ e ];
r.tag = 0;
return r;
}
function push(e) {
var t = [ e ];
t.tag = r.Push;
return t;
var r = [ e ];
r.tag = 1;
return r;
}

@@ -39,35 +24,35 @@

function concatMap(l) {
return s => n => {
var a = [];
var i = t;
var f = t;
function concatMap(r) {
return t => i => {
var s = [];
var a = e;
var f = e;
var n = !1;
var l = !1;
var o = !1;
var u = !1;
var v = !1;
var c = !1;
function applyInnerSource(t) {
v = !0;
t((t => {
if (t === r.End) {
if (v) {
v = !1;
if (a.length) {
applyInnerSource(l(a.shift()));
} else if (c) {
n(r.End);
} else if (!o) {
o = !0;
i(e.Pull);
function applyInnerSource(e) {
o = !0;
e((e => {
if (0 === e) {
if (o) {
o = !1;
if (s.length) {
applyInnerSource(r(s.shift()));
} else if (u) {
i(0);
} else if (!n) {
n = !0;
a(0);
}
}
} else if (t.tag === r.Start) {
u = !1;
(f = t[0])(e.Pull);
} else if (v) {
n(t);
if (u) {
u = !1;
} else if (0 === e.tag) {
l = !1;
(f = e[0])(0);
} else if (o) {
i(e);
if (l) {
l = !1;
} else {
f(e.Pull);
f(0);
}

@@ -77,37 +62,37 @@ }

}
s((e => {
if (c) {} else if (e === r.End) {
c = !0;
if (!v && !a.length) {
n(r.End);
t((e => {
if (u) {} else if (0 === e) {
u = !0;
if (!o && !s.length) {
i(0);
}
} else if (e.tag === r.Start) {
i = e[0];
} else if (0 === e.tag) {
a = e[0];
} else {
o = !1;
if (v) {
a.push(e[0]);
n = !1;
if (o) {
s.push(e[0]);
} else {
applyInnerSource(l(e[0]));
applyInnerSource(r(e[0]));
}
}
}));
n(start((r => {
if (r === e.Close) {
if (!c) {
c = !0;
i(e.Close);
i(start((e => {
if (1 === e) {
if (!u) {
u = !0;
a(1);
}
if (v) {
v = !1;
f(e.Close);
if (o) {
o = !1;
f(1);
}
} else {
if (!c && !o) {
o = !0;
i(e.Pull);
if (!u && !n) {
n = !0;
a(0);
}
if (v && !u) {
u = !0;
f(e.Pull);
if (o && !l) {
l = !0;
f(0);
}

@@ -123,70 +108,70 @@ }

function mergeMap(l) {
return s => n => {
var a = [];
var i = t;
function mergeMap(r) {
return t => i => {
var s = [];
var a = e;
var f = !1;
var o = !1;
s((s => {
if (o) {} else if (s === r.End) {
o = !0;
if (!a.length) {
n(r.End);
var n = !1;
t((t => {
if (n) {} else if (0 === t) {
n = !0;
if (!s.length) {
i(0);
}
} else if (s.tag === r.Start) {
i = s[0];
} else if (0 === t.tag) {
a = t[0];
} else {
f = !1;
!function applyInnerSource(l) {
var s = t;
l((t => {
if (t === r.End) {
if (a.length) {
var l = a.indexOf(s);
if (l > -1) {
(a = a.slice()).splice(l, 1);
!function applyInnerSource(r) {
var t = e;
r((e => {
if (0 === e) {
if (s.length) {
var r = s.indexOf(t);
if (r > -1) {
(s = s.slice()).splice(r, 1);
}
if (!a.length) {
if (o) {
n(r.End);
if (!s.length) {
if (n) {
i(0);
} else if (!f) {
f = !0;
i(e.Pull);
a(0);
}
}
}
} else if (t.tag === r.Start) {
a.push(s = t[0]);
s(e.Pull);
} else if (a.length) {
n(t);
s(e.Pull);
} else if (0 === e.tag) {
s.push(t = e[0]);
t(0);
} else if (s.length) {
i(e);
t(0);
}
}));
}(l(s[0]));
}(r(t[0]));
if (!f) {
f = !0;
i(e.Pull);
a(0);
}
}
}));
n(start((r => {
if (r === e.Close) {
if (!o) {
o = !0;
i(e.Close);
i(start((e => {
if (1 === e) {
if (!n) {
n = !0;
a(1);
}
for (var t = 0, l = a, s = a.length; t < s; t++) {
l[t](e.Close);
for (var r = 0, t = s, i = s.length; r < i; r++) {
t[r](1);
}
a.length = 0;
s.length = 0;
} else {
if (!o && !f) {
if (!n && !f) {
f = !0;
i(e.Pull);
a(0);
} else {
f = !1;
}
for (var n = 0, u = a, v = a.length; n < v; n++) {
u[n](e.Pull);
for (var l = 0, o = s, u = s.length; l < u; l++) {
o[l](0);
}

@@ -202,20 +187,20 @@ }

function onPush(t) {
return l => s => {
var n = !1;
l((l => {
if (n) {} else if (l === r.End) {
n = !0;
s(r.End);
} else if (l.tag === r.Start) {
var a = l[0];
s(start((r => {
if (r === e.Close) {
n = !0;
function onPush(e) {
return r => t => {
var i = !1;
r((r => {
if (i) {} else if (0 === r) {
i = !0;
t(0);
} else if (0 === r.tag) {
var s = r[0];
t(start((e => {
if (1 === e) {
i = !0;
}
a(r);
s(e);
})));
} else {
t(l[0]);
s(l);
e(r[0]);
t(r);
}

@@ -226,21 +211,21 @@ }));

function share(l) {
var s = [];
var n = t;
var a = !1;
return t => {
s.push(t);
if (1 === s.length) {
l((e => {
if (e === r.End) {
for (var t = 0, l = s, i = s.length; t < i; t++) {
l[t](r.End);
function share(r) {
var t = [];
var i = e;
var s = !1;
return e => {
t.push(e);
if (1 === t.length) {
r((e => {
if (0 === e) {
for (var r = 0, a = t, f = t.length; r < f; r++) {
a[r](0);
}
s.length = 0;
} else if (e.tag === r.Start) {
n = e[0];
t.length = 0;
} else if (0 === e.tag) {
i = e[0];
} else {
a = !1;
for (var f = 0, o = s, u = s.length; f < u; f++) {
o[f](e);
s = !1;
for (var n = 0, l = t, o = t.length; n < o; n++) {
l[n](e);
}

@@ -250,14 +235,14 @@ }

}
t(start((r => {
if (r === e.Close) {
var l = s.indexOf(t);
if (l > -1) {
(s = s.slice()).splice(l, 1);
e(start((r => {
if (1 === r) {
var a = t.indexOf(e);
if (a > -1) {
(t = t.slice()).splice(a, 1);
}
if (!s.length) {
n(e.Close);
if (!t.length) {
i(1);
}
} else if (!a) {
a = !0;
n(e.Pull);
} else if (!s) {
s = !0;
i(0);
}

@@ -268,73 +253,73 @@ })));

function switchMap(l) {
return s => n => {
var a = t;
var i = t;
function switchMap(r) {
return t => i => {
var s = e;
var a = e;
var f = !1;
var n = !1;
var l = !1;
var o = !1;
var u = !1;
var v = !1;
s((s => {
if (v) {} else if (s === r.End) {
v = !0;
if (!u) {
n(r.End);
t((t => {
if (o) {} else if (0 === t) {
o = !0;
if (!l) {
i(0);
}
} else if (s.tag === r.Start) {
a = s[0];
} else if (0 === t.tag) {
s = t[0];
} else {
if (u) {
i(e.Close);
i = t;
if (l) {
a(1);
a = e;
}
if (!f) {
f = !0;
a(e.Pull);
s(0);
} else {
f = !1;
}
!function applyInnerSource(t) {
u = !0;
t((t => {
if (!u) {} else if (t === r.End) {
u = !1;
if (v) {
n(r.End);
!function applyInnerSource(e) {
l = !0;
e((e => {
if (!l) {} else if (0 === e) {
l = !1;
if (o) {
i(0);
} else if (!f) {
f = !0;
a(e.Pull);
s(0);
}
} else if (t.tag === r.Start) {
o = !1;
(i = t[0])(e.Pull);
} else if (0 === e.tag) {
n = !1;
(a = e[0])(0);
} else {
n(t);
if (!o) {
i(e.Pull);
i(e);
if (!n) {
a(0);
} else {
o = !1;
n = !1;
}
}
}));
}(l(s[0]));
}(r(t[0]));
}
}));
n(start((r => {
if (r === e.Close) {
if (!v) {
v = !0;
a(e.Close);
i(start((e => {
if (1 === e) {
if (!o) {
o = !0;
s(1);
}
if (u) {
u = !1;
i(e.Close);
if (l) {
l = !1;
a(1);
}
} else {
if (!v && !f) {
if (!o && !f) {
f = !0;
a(e.Pull);
s(0);
}
if (u && !o) {
o = !0;
i(e.Pull);
if (l && !n) {
n = !0;
a(0);
}

@@ -346,33 +331,33 @@ }

function fromAsyncIterable(t) {
return l => {
var s = t[Symbol.asyncIterator]();
var n = !1;
function fromAsyncIterable(e) {
return r => {
var t = e[Symbol.asyncIterator]();
var i = !1;
var s = !1;
var a = !1;
var i = !1;
var f;
l(start((async t => {
if (t === e.Close) {
n = !0;
if (s.return) {
s.return();
r(start((async e => {
if (1 === e) {
i = !0;
if (t.return) {
t.return();
}
} else if (a) {
i = !0;
} else if (s) {
a = !0;
} else {
for (i = a = !0; i && !n; ) {
if ((f = await s.next()).done) {
n = !0;
if (s.return) {
await s.return();
for (a = s = !0; a && !i; ) {
if ((f = await t.next()).done) {
i = !0;
if (t.return) {
await t.return();
}
l(r.End);
r(0);
} else {
try {
i = !1;
l(push(f.value));
a = !1;
r(push(f.value));
} catch (e) {
if (s.throw) {
if (n = !!(await s.throw(e)).done) {
l(r.End);
if (t.throw) {
if (i = !!(await t.throw(e)).done) {
r(0);
}

@@ -385,3 +370,3 @@ } else {

}
a = !1;
s = !1;
}

@@ -392,36 +377,36 @@ })));

function fromIterable(t) {
if (t[Symbol.asyncIterator]) {
return fromAsyncIterable(t);
function fromIterable(e) {
if (e[Symbol.asyncIterator]) {
return fromAsyncIterable(e);
}
return l => {
var s = t[Symbol.iterator]();
var n = !1;
return r => {
var t = e[Symbol.iterator]();
var i = !1;
var s = !1;
var a = !1;
var i = !1;
var f;
l(start((t => {
if (t === e.Close) {
n = !0;
if (s.return) {
s.return();
r(start((e => {
if (1 === e) {
i = !0;
if (t.return) {
t.return();
}
} else if (a) {
i = !0;
} else if (s) {
a = !0;
} else {
for (i = a = !0; i && !n; ) {
if ((f = s.next()).done) {
n = !0;
if (s.return) {
s.return();
for (a = s = !0; a && !i; ) {
if ((f = t.next()).done) {
i = !0;
if (t.return) {
t.return();
}
l(r.End);
r(0);
} else {
try {
i = !1;
l(push(f.value));
a = !1;
r(push(f.value));
} catch (e) {
if (s.throw) {
if (n = !!s.throw(e).done) {
l(r.End);
if (t.throw) {
if (i = !!t.throw(e).done) {
r(0);
}

@@ -434,3 +419,3 @@ } else {

}
a = !1;
s = !1;
}

@@ -441,24 +426,24 @@ })));

var l = fromIterable;
var r = fromIterable;
function make(t) {
return l => {
var s = !1;
var n = t({
function make(e) {
return r => {
var t = !1;
var i = e({
next(e) {
if (!s) {
l(push(e));
if (!t) {
r(push(e));
}
},
complete() {
if (!s) {
s = !0;
l(r.End);
if (!t) {
t = !0;
r(0);
}
}
});
l(start((r => {
if (r === e.Close && !s) {
s = !0;
n();
r(start((e => {
if (1 === e && !t) {
t = !0;
i();
}

@@ -469,14 +454,14 @@ })));

function subscribe(l) {
return s => {
var n = t;
var a = !1;
s((t => {
if (t === r.End) {
a = !0;
} else if (t.tag === r.Start) {
(n = t[0])(e.Pull);
} else if (!a) {
l(t[0]);
n(e.Pull);
function subscribe(r) {
return t => {
var i = e;
var s = !1;
t((e => {
if (0 === e) {
s = !0;
} else if (0 === e.tag) {
(i = e[0])(0);
} else if (!s) {
r(e[0]);
i(0);
}

@@ -486,5 +471,5 @@ }));

unsubscribe() {
if (!a) {
a = !0;
n(e.Close);
if (!s) {
s = !0;
i(1);
}

@@ -496,44 +481,44 @@ }

var s = {
var t = {
done: !0
};
function zip(l) {
var s = Object.keys(l).length;
return n => {
var a = new Set;
var i = Array.isArray(l) ? new Array(s).fill(t) : {};
var f = Array.isArray(l) ? new Array(s) : {};
function zip(r) {
var t = Object.keys(r).length;
return i => {
var s = new Set;
var a = Array.isArray(r) ? new Array(t).fill(e) : {};
var f = Array.isArray(r) ? new Array(t) : {};
var n = !1;
var l = !1;
var o = !1;
var u = !1;
var v = !1;
var c = 0;
var loop = function(p) {
l[p]((d => {
if (d === r.End) {
if (c >= s - 1) {
v = !0;
n(r.End);
var u = 0;
var loop = function(v) {
r[v]((c => {
if (0 === c) {
if (u >= t - 1) {
o = !0;
i(0);
} else {
c++;
u++;
}
} else if (d.tag === r.Start) {
i[p] = d[0];
} else if (!v) {
f[p] = d[0];
a.add(p);
if (!o && a.size < s) {
if (!u) {
for (var h in l) {
if (!a.has(h)) {
(i[h] || t)(e.Pull);
} else if (0 === c.tag) {
a[v] = c[0];
} else if (!o) {
f[v] = c[0];
s.add(v);
if (!n && s.size < t) {
if (!l) {
for (var p in r) {
if (!s.has(p)) {
(a[p] || e)(0);
}
}
} else {
u = !1;
l = !1;
}
} else {
o = !0;
u = !1;
n(push(Array.isArray(f) ? f.slice() : {
n = !0;
l = !1;
i(push(Array.isArray(f) ? f.slice() : {
...f

@@ -545,15 +530,15 @@ }));

};
for (var p in l) {
loop(p);
for (var v in r) {
loop(v);
}
n(start((r => {
if (v) {} else if (r === e.Close) {
v = !0;
for (var t in i) {
i[t](e.Close);
i(start((e => {
if (o) {} else if (1 === e) {
o = !0;
for (var r in a) {
a[r](1);
}
} else if (!u) {
u = !0;
for (var l in i) {
i[l](e.Pull);
} else if (!l) {
l = !0;
for (var t in a) {
a[t](0);
}

@@ -567,55 +552,55 @@ }

exports.buffer = function buffer(l) {
return s => n => {
var a = [];
var i = t;
var f = t;
var o = !1;
var u = !1;
s((t => {
if (u) {} else if (t === r.End) {
u = !0;
f(e.Close);
if (a.length) {
n(push(a));
exports.buffer = function buffer(r) {
return t => i => {
var s = [];
var a = e;
var f = e;
var n = !1;
var l = !1;
t((e => {
if (l) {} else if (0 === e) {
l = !0;
f(1);
if (s.length) {
i(push(s));
}
n(r.End);
} else if (t.tag === r.Start) {
i = t[0];
l((t => {
if (u) {} else if (t === r.End) {
u = !0;
i(e.Close);
if (a.length) {
n(push(a));
i(0);
} else if (0 === e.tag) {
a = e[0];
r((e => {
if (l) {} else if (0 === e) {
l = !0;
a(1);
if (s.length) {
i(push(s));
}
n(r.End);
} else if (t.tag === r.Start) {
f = t[0];
} else if (a.length) {
var l = push(a);
a = [];
n(l);
i(0);
} else if (0 === e.tag) {
f = e[0];
} else if (s.length) {
var r = push(s);
s = [];
i(r);
}
}));
} else {
a.push(t[0]);
if (!o) {
o = !0;
i(e.Pull);
f(e.Pull);
s.push(e[0]);
if (!n) {
n = !0;
a(0);
f(0);
} else {
o = !1;
n = !1;
}
}
}));
n(start((r => {
if (r === e.Close && !u) {
u = !0;
i(e.Close);
f(e.Close);
} else if (!u && !o) {
o = !0;
i(e.Pull);
f(e.Pull);
i(start((e => {
if (1 === e && !l) {
l = !0;
a(1);
f(1);
} else if (!l && !n) {
n = !0;
a(0);
f(0);
}

@@ -631,3 +616,3 @@ })));

exports.concat = function concat(e) {
return concatAll(l(e));
return concatAll(r(e));
};

@@ -639,40 +624,40 @@

exports.debounce = function debounce(t) {
return l => s => {
var n;
exports.debounce = function debounce(e) {
return r => t => {
var i;
var s = !1;
var a = !1;
var i = !1;
l((l => {
if (i) {} else if (l === r.End) {
i = !0;
if (n) {
a = !0;
r((r => {
if (a) {} else if (0 === r) {
a = !0;
if (i) {
s = !0;
} else {
s(r.End);
t(0);
}
} else if (l.tag === r.Start) {
var f = l[0];
s(start((r => {
if (r === e.Close && !i) {
i = !0;
a = !1;
if (n) {
clearTimeout(n);
} else if (0 === r.tag) {
var f = r[0];
t(start((e => {
if (1 === e && !a) {
a = !0;
s = !1;
if (i) {
clearTimeout(i);
}
f(e.Close);
} else if (!i) {
f(e.Pull);
f(1);
} else if (!a) {
f(0);
}
})));
} else {
if (n) {
clearTimeout(n);
if (i) {
clearTimeout(i);
}
n = setTimeout((() => {
n = void 0;
s(l);
if (a) {
s(r.End);
i = setTimeout((() => {
i = void 0;
t(r);
if (s) {
t(0);
}
}), t(l[0]));
}), e(r[0]));
}

@@ -684,13 +669,13 @@ }));

exports.delay = function delay(e) {
return t => l => {
var s = 0;
t((t => {
if (t !== r.End && t.tag === r.Start) {
l(t);
return r => t => {
var i = 0;
r((r => {
if (0 !== r && 0 === r.tag) {
t(r);
} else {
s++;
i++;
setTimeout((() => {
if (s) {
s--;
l(t);
if (i) {
i--;
t(r);
}

@@ -703,10 +688,10 @@ }), e);

exports.empty = t => {
var l = !1;
t(start((s => {
if (s === e.Close) {
l = !0;
} else if (!l) {
l = !0;
t(r.End);
exports.empty = e => {
var r = !1;
e(start((t => {
if (1 === t) {
r = !0;
} else if (!r) {
r = !0;
e(0);
}

@@ -716,15 +701,15 @@ })));

exports.filter = function filter(l) {
return s => n => {
var a = t;
s((t => {
if (t === r.End) {
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
n(t);
} else if (!l(t[0])) {
a(e.Pull);
exports.filter = function filter(r) {
return t => i => {
var s = e;
t((e => {
if (0 === e) {
i(0);
} else if (0 === e.tag) {
s = e[0];
i(e);
} else if (!r(e[0])) {
s(0);
} else {
n(t);
i(e);
}

@@ -743,3 +728,3 @@ }));

exports.fromArray = l;
exports.fromArray = r;

@@ -749,12 +734,12 @@ exports.fromAsyncIterable = fromAsyncIterable;

exports.fromCallbag = function fromCallbag(e) {
return t => {
e(0, ((e, l) => {
return r => {
e(0, ((e, t) => {
if (0 === e) {
t(start((e => {
l(e + 1);
r(start((e => {
t(e + 1);
})));
} else if (1 === e) {
t(push(l));
r(push(t));
} else {
t(r.End);
r(0);
}

@@ -774,10 +759,10 @@ }));

exports.fromObservable = function fromObservable(t) {
return l => {
var s = (t[observableSymbol()] ? t[observableSymbol()]() : t).subscribe({
exports.fromObservable = function fromObservable(e) {
return r => {
var t = (e[observableSymbol()] ? e[observableSymbol()]() : e).subscribe({
next(e) {
l(push(e));
r(push(e));
},
complete() {
l(r.End);
r(0);
},

@@ -788,5 +773,5 @@ error(e) {

});
l(start((r => {
if (r === e.Close) {
s.unsubscribe();
r(start((e => {
if (1 === e) {
t.unsubscribe();
}

@@ -809,12 +794,12 @@ })));

exports.fromValue = function fromValue(t) {
return l => {
var s = !1;
l(start((n => {
if (n === e.Close) {
s = !0;
} else if (!s) {
s = !0;
l(push(t));
l(r.End);
exports.fromValue = function fromValue(e) {
return r => {
var t = !1;
r(start((i => {
if (1 === i) {
t = !0;
} else if (!t) {
t = !0;
r(push(e));
r(0);
}

@@ -828,4 +813,4 @@ })));

var t = 0;
var l = setInterval((() => r.next(t++)), e);
return () => clearInterval(l);
var i = setInterval((() => r.next(t++)), e);
return () => clearInterval(i);
}));

@@ -863,7 +848,7 @@ };

exports.map = function map(e) {
return t => l => t((t => {
if (t === r.End || t.tag === r.Start) {
l(t);
return r => t => r((r => {
if (0 === r || 0 === r.tag) {
t(r);
} else {
l(push(e(t[0])));
t(push(e(r[0])));
}

@@ -874,3 +859,3 @@ }));

exports.merge = function merge(e) {
return mergeAll(l(e));
return mergeAll(r(e));
};

@@ -882,27 +867,27 @@

exports.never = e => {
e(start(t));
exports.never = r => {
r(start(e));
};
exports.onEnd = function onEnd(t) {
return l => s => {
var n = !1;
l((l => {
if (n) {} else if (l === r.End) {
n = !0;
s(r.End);
t();
} else if (l.tag === r.Start) {
var a = l[0];
s(start((r => {
if (r === e.Close) {
n = !0;
a(e.Close);
t();
exports.onEnd = function onEnd(e) {
return r => t => {
var i = !1;
r((r => {
if (i) {} else if (0 === r) {
i = !0;
t(0);
e();
} else if (0 === r.tag) {
var s = r[0];
t(start((r => {
if (1 === r) {
i = !0;
s(1);
e();
} else {
a(r);
s(r);
}
})));
} else {
s(l);
t(r);
}

@@ -916,10 +901,10 @@ }));

exports.onStart = function onStart(e) {
return t => l => t((t => {
if (t === r.End) {
l(r.End);
} else if (t.tag === r.Start) {
l(t);
return r => t => r((r => {
if (0 === r) {
t(0);
} else if (0 === r.tag) {
t(r);
e();
} else {
l(t);
t(r);
}

@@ -931,3 +916,3 @@ }));

var r = e[0];
for (var t = 1, l = e.length; t < l; t++) {
for (var t = 1, i = e.length; t < i; t++) {
r = e[t](r);

@@ -942,49 +927,49 @@ }

exports.sample = function sample(l) {
return s => n => {
var a = t;
var i = t;
exports.sample = function sample(r) {
return t => i => {
var s = e;
var a = e;
var f;
var o = !1;
var u = !1;
s((t => {
if (u) {} else if (t === r.End) {
u = !0;
i(e.Close);
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
var n = !1;
var l = !1;
t((e => {
if (l) {} else if (0 === e) {
l = !0;
a(1);
i(0);
} else if (0 === e.tag) {
s = e[0];
} else {
f = t[0];
if (!o) {
o = !0;
i(e.Pull);
a(e.Pull);
f = e[0];
if (!n) {
n = !0;
a(0);
s(0);
} else {
o = !1;
n = !1;
}
}
}));
l((t => {
if (u) {} else if (t === r.End) {
u = !0;
a(e.Close);
n(r.End);
} else if (t.tag === r.Start) {
i = t[0];
r((e => {
if (l) {} else if (0 === e) {
l = !0;
s(1);
i(0);
} else if (0 === e.tag) {
a = e[0];
} else if (void 0 !== f) {
var l = push(f);
var r = push(f);
f = void 0;
n(l);
i(r);
}
}));
n(start((r => {
if (r === e.Close && !u) {
u = !0;
a(e.Close);
i(e.Close);
} else if (!u && !o) {
o = !0;
a(e.Pull);
i(e.Pull);
i(start((e => {
if (1 === e && !l) {
l = !0;
s(1);
a(1);
} else if (!l && !n) {
n = !0;
s(0);
a(0);
}

@@ -995,12 +980,12 @@ })));

exports.scan = function scan(e, t) {
return l => s => {
var n = t;
l((t => {
if (t === r.End) {
s(r.End);
} else if (t.tag === r.Start) {
s(t);
exports.scan = function scan(e, r) {
return t => i => {
var s = r;
t((r => {
if (0 === r) {
i(0);
} else if (0 === r.tag) {
i(r);
} else {
s(push(n = e(n, t[0])));
i(push(s = e(s, r[0])));
}

@@ -1013,16 +998,16 @@ }));

exports.skip = function skip(l) {
return s => n => {
var a = t;
var i = l;
s((t => {
if (t === r.End) {
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
n(t);
} else if (i-- > 0) {
a(e.Pull);
exports.skip = function skip(r) {
return t => i => {
var s = e;
var a = r;
t((e => {
if (0 === e) {
i(0);
} else if (0 === e.tag) {
s = e[0];
i(e);
} else if (a-- > 0) {
s(0);
} else {
n(t);
i(e);
}

@@ -1033,55 +1018,55 @@ }));

exports.skipUntil = function skipUntil(l) {
return s => n => {
var a = t;
var i = t;
exports.skipUntil = function skipUntil(r) {
return t => i => {
var s = e;
var a = e;
var f = !0;
var o = !1;
var u = !1;
s((t => {
if (u) {} else if (t === r.End) {
u = !0;
var n = !1;
var l = !1;
t((e => {
if (l) {} else if (0 === e) {
l = !0;
if (f) {
i(e.Close);
a(1);
}
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
l((t => {
if (t === r.End) {
i(0);
} else if (0 === e.tag) {
s = e[0];
r((e => {
if (0 === e) {
if (f) {
u = !0;
a(e.Close);
l = !0;
s(1);
}
} else if (t.tag === r.Start) {
(i = t[0])(e.Pull);
} else if (0 === e.tag) {
(a = e[0])(0);
} else {
f = !1;
i(e.Close);
a(1);
}
}));
} else if (!f) {
o = !1;
n(t);
} else if (!o) {
o = !0;
a(e.Pull);
i(e.Pull);
n = !1;
i(e);
} else if (!n) {
n = !0;
s(0);
a(0);
} else {
o = !1;
n = !1;
}
}));
n(start((r => {
if (r === e.Close && !u) {
u = !0;
a(e.Close);
i(start((e => {
if (1 === e && !l) {
l = !0;
s(1);
if (f) {
i(e.Close);
a(1);
}
} else if (!u && !o) {
o = !0;
} else if (!l && !n) {
n = !0;
if (f) {
i(e.Pull);
a(0);
}
a(e.Pull);
s(0);
}

@@ -1092,21 +1077,21 @@ })));

exports.skipWhile = function skipWhile(l) {
return s => n => {
var a = t;
var i = !0;
s((t => {
if (t === r.End) {
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
n(t);
} else if (i) {
if (l(t[0])) {
a(e.Pull);
exports.skipWhile = function skipWhile(r) {
return t => i => {
var s = e;
var a = !0;
t((e => {
if (0 === e) {
i(0);
} else if (0 === e.tag) {
s = e[0];
i(e);
} else if (a) {
if (r(e[0])) {
s(0);
} else {
i = !1;
n(t);
a = !1;
i(e);
}
} else {
n(t);
i(e);
}

@@ -1125,36 +1110,36 @@ }));

exports.take = function take(l) {
return s => n => {
var a = t;
var i = !1;
exports.take = function take(r) {
return t => i => {
var s = e;
var a = !1;
var f = 0;
s((t => {
if (i) {} else if (t === r.End) {
i = !0;
n(r.End);
} else if (t.tag === r.Start) {
if (l <= 0) {
i = !0;
n(r.End);
t[0](e.Close);
t((e => {
if (a) {} else if (0 === e) {
a = !0;
i(0);
} else if (0 === e.tag) {
if (r <= 0) {
a = !0;
i(0);
e[0](1);
} else {
a = t[0];
s = e[0];
}
} else if (f++ < l) {
n(t);
if (!i && f >= l) {
i = !0;
n(r.End);
a(e.Close);
} else if (f++ < r) {
i(e);
if (!a && f >= r) {
a = !0;
i(0);
s(1);
}
} else {
n(t);
i(e);
}
}));
n(start((r => {
if (r === e.Close && !i) {
i = !0;
a(e.Close);
} else if (r === e.Pull && !i && f < l) {
a(e.Pull);
i(start((e => {
if (1 === e && !a) {
a = !0;
s(1);
} else if (0 === e && !a && f < r) {
s(0);
}

@@ -1165,22 +1150,22 @@ })));

exports.takeLast = function takeLast(s) {
return n => a => {
var i = [];
var f = t;
n((t => {
if (t === r.End) {
l(i)(a);
} else if (t.tag === r.Start) {
if (s <= 0) {
t[0](e.Close);
l(i)(a);
exports.takeLast = function takeLast(t) {
return i => s => {
var a = [];
var f = e;
i((e => {
if (0 === e) {
r(a)(s);
} else if (0 === e.tag) {
if (t <= 0) {
e[0](1);
r(a)(s);
} else {
(f = t[0])(e.Pull);
(f = e[0])(0);
}
} else {
if (i.length >= s && s) {
i.shift();
if (a.length >= t && t) {
a.shift();
}
i.push(t[0]);
f(e.Pull);
a.push(e[0]);
f(0);
}

@@ -1191,35 +1176,35 @@ }));

exports.takeUntil = function takeUntil(l) {
return s => n => {
var a = t;
var i = t;
exports.takeUntil = function takeUntil(r) {
return t => i => {
var s = e;
var a = e;
var f = !1;
s((t => {
if (f) {} else if (t === r.End) {
t((e => {
if (f) {} else if (0 === e) {
f = !0;
i(e.Close);
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
l((t => {
if (t === r.End) {} else if (t.tag === r.Start) {
(i = t[0])(e.Pull);
a(1);
i(0);
} else if (0 === e.tag) {
s = e[0];
r((e => {
if (0 === e) {} else if (0 === e.tag) {
(a = e[0])(0);
} else {
f = !0;
i(e.Close);
a(e.Close);
n(r.End);
a(1);
s(1);
i(0);
}
}));
} else {
n(t);
i(e);
}
}));
n(start((r => {
if (r === e.Close && !f) {
i(start((e => {
if (1 === e && !f) {
f = !0;
a(e.Close);
i(e.Close);
s(1);
a(1);
} else if (!f) {
a(e.Pull);
s(0);
}

@@ -1230,19 +1215,19 @@ })));

exports.takeWhile = function takeWhile(l) {
return s => n => {
var a = t;
var i = !1;
s((t => {
if (i) {} else if (t === r.End) {
i = !0;
n(r.End);
} else if (t.tag === r.Start) {
a = t[0];
n(t);
} else if (!l(t[0])) {
i = !0;
n(r.End);
a(e.Close);
exports.takeWhile = function takeWhile(r) {
return t => i => {
var s = e;
var a = !1;
t((e => {
if (a) {} else if (0 === e) {
a = !0;
i(0);
} else if (0 === e.tag) {
s = e[0];
i(e);
} else if (!r(e[0])) {
a = !0;
i(0);
s(1);
} else {
n(t);
i(e);
}

@@ -1255,34 +1240,34 @@ }));

exports.throttle = function throttle(t) {
return l => s => {
var n = !1;
var a;
l((l => {
if (l === r.End) {
if (a) {
clearTimeout(a);
exports.throttle = function throttle(e) {
return r => t => {
var i = !1;
var s;
r((r => {
if (0 === r) {
if (s) {
clearTimeout(s);
}
s(r.End);
} else if (l.tag === r.Start) {
var i = l[0];
s(start((r => {
if (r === e.Close) {
if (a) {
clearTimeout(a);
t(0);
} else if (0 === r.tag) {
var a = r[0];
t(start((e => {
if (1 === e) {
if (s) {
clearTimeout(s);
}
i(e.Close);
a(1);
} else {
i(e.Pull);
a(0);
}
})));
} else if (!n) {
n = !0;
if (a) {
clearTimeout(a);
} else if (!i) {
i = !0;
if (s) {
clearTimeout(s);
}
a = setTimeout((() => {
a = void 0;
n = !1;
}), t(l[0]));
s(l);
s = setTimeout((() => {
s = void 0;
i = !1;
}), e(r[0]));
t(r);
}

@@ -1293,43 +1278,43 @@ }));

exports.toArray = function toArray(l) {
var s = [];
var n = t;
var a = !1;
l((t => {
if (t === r.End) {
a = !0;
} else if (t.tag === r.Start) {
(n = t[0])(e.Pull);
exports.toArray = function toArray(r) {
var t = [];
var i = e;
var s = !1;
r((e => {
if (0 === e) {
s = !0;
} else if (0 === e.tag) {
(i = e[0])(0);
} else {
s.push(t[0]);
n(e.Pull);
t.push(e[0]);
i(0);
}
}));
if (!a) {
n(e.Close);
if (!s) {
i(1);
}
return s;
return t;
};
exports.toAsyncIterable = l => ({
exports.toAsyncIterable = r => ({
[Symbol.asyncIterator]() {
var n = [];
var a = !1;
var i = t;
var i = [];
var s = !1;
var a = e;
var f;
l((t => {
if (a) {} else if (t === r.End) {
r((e => {
if (s) {} else if (0 === e) {
if (f) {
f = f(s);
f = f(t);
}
a = !0;
} else if (t.tag === r.Start) {
(i = t[0])(e.Pull);
s = !0;
} else if (0 === e.tag) {
(a = e[0])(0);
} else if (f) {
f = f({
value: t[0],
value: e[0],
done: !1
});
} else {
n.push(t[0]);
i.push(e[0]);
}

@@ -1339,9 +1324,9 @@ }));

async next() {
if (a && !n.length) {
return s;
} else if (!a && n.length <= 1) {
i(e.Pull);
if (s && !i.length) {
return t;
} else if (!s && i.length <= 1) {
a(0);
}
return n.length ? {
value: n.shift(),
return i.length ? {
value: i.shift(),
done: !1

@@ -1351,7 +1336,7 @@ } : new Promise((e => f = e));

async return() {
if (!a) {
f = i(e.Close);
if (!s) {
f = a(1);
}
a = !0;
return s;
s = !0;
return t;
}

@@ -1363,9 +1348,9 @@ };

exports.toCallbag = function toCallbag(e) {
return (t, l) => {
if (0 === t) {
return (r, t) => {
if (0 === r) {
e((e => {
if (e === r.End) {
l(2);
} else if (e.tag === r.Start) {
l(0, (r => {
if (0 === e) {
t(2);
} else if (0 === e.tag) {
t(0, (r => {
if (r < 3) {

@@ -1376,3 +1361,3 @@ e[0](r - 1);

} else {
l(1, e[0]);
t(1, e[0]);
}

@@ -1384,34 +1369,34 @@ }));

exports.toObservable = function toObservable(l) {
exports.toObservable = function toObservable(r) {
return {
subscribe(s, n, a) {
var i = "object" == typeof s ? s : {
next: s,
error: n,
complete: a
subscribe(t, i, s) {
var a = "object" == typeof t ? t : {
next: t,
error: i,
complete: s
};
var f = t;
var o = !1;
l((t => {
if (o) {} else if (t === r.End) {
o = !0;
if (i.complete) {
i.complete();
var f = e;
var n = !1;
r((e => {
if (n) {} else if (0 === e) {
n = !0;
if (a.complete) {
a.complete();
}
} else if (t.tag === r.Start) {
(f = t[0])(e.Pull);
} else if (0 === e.tag) {
(f = e[0])(0);
} else {
i.next(t[0]);
f(e.Pull);
a.next(e[0]);
f(0);
}
}));
var u = {
var l = {
closed: !1,
unsubscribe() {
u.closed = !0;
o = !0;
f(e.Close);
l.closed = !0;
n = !0;
f(1);
}
};
return u;
return l;
},

@@ -1424,14 +1409,14 @@ [observableSymbol()]() {

exports.toPromise = function toPromise(l) {
return new Promise((s => {
var n = t;
var a;
l((t => {
if (t === r.End) {
Promise.resolve(a).then(s);
} else if (t.tag === r.Start) {
(n = t[0])(e.Pull);
exports.toPromise = function toPromise(r) {
return new Promise((t => {
var i = e;
var s;
r((e => {
if (0 === e) {
Promise.resolve(s).then(t);
} else if (0 === e.tag) {
(i = e[0])(0);
} else {
a = t[0];
n(e.Pull);
s = e[0];
i(0);
}

@@ -1438,0 +1423,0 @@ }));

{
"name": "wonka",
"description": "A tiny but capable push & pull stream library for TypeScript and Flow",
"version": "0.0.0-canary-20230321073435",
"version": "0.0.0-canary-20230326035503",
"author": "0no.co <hi@0no.co>",

@@ -6,0 +6,0 @@ "source": "./src/index.ts",

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