Comparing version 6.1.1 to 6.1.2
@@ -1147,2 +1147,3 @@ Object.defineProperty(exports, "__esModule", { | ||
f = !0; | ||
a(1); | ||
s(1); | ||
@@ -1149,0 +1150,0 @@ i(0); |
{ | ||
"name": "wonka", | ||
"description": "A tiny but capable push & pull stream library for TypeScript and Flow", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -6,0 +6,0 @@ "source": "./src/index.ts", |
@@ -509,2 +509,28 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
}); | ||
it('completes the source when no more sink is listening', () => { | ||
let onPush = () => {}; | ||
const talkback = vi.fn(); | ||
const source: Source<any> = operators.share(sink => { | ||
sink(start(talkback)); | ||
onPush = () => { | ||
sink(push([0])); | ||
sink(push([1])); | ||
sink(SignalKind.End); | ||
}; | ||
}); | ||
const fnA = vi.fn(); | ||
const fnB = vi.fn(); | ||
sinks.forEach(fnA)(operators.take(1)(source)); | ||
sinks.forEach(fnB)(operators.take(1)(source)); | ||
onPush(); | ||
expect(fnA).toHaveBeenCalledWith([0]); | ||
expect(fnB).toHaveBeenCalledWith([0]); | ||
expect(fnA.mock.calls[0][0]).toBe(fnB.mock.calls[0][0]); | ||
expect(talkback).toHaveBeenCalledWith(TalkbackKind.Close); | ||
}); | ||
}); | ||
@@ -701,2 +727,28 @@ | ||
}); | ||
it('emits values until a notifier emits', () => { | ||
const { source: input$, next } = sources.makeSubject<number>(); | ||
const fn = vi.fn(); | ||
let hasClosed = false; | ||
operators.takeUntil(sink => { | ||
sink( | ||
start(talkback => { | ||
if (talkback === TalkbackKind.Close) { | ||
hasClosed = true; | ||
} else if (talkback === TalkbackKind.Pull && !hasClosed) { | ||
sink(push(1)); | ||
} | ||
}) | ||
); | ||
})(input$)(fn); | ||
next(1); | ||
expect(fn).toHaveBeenCalledTimes(2); | ||
expect(fn.mock.calls).toEqual([[0], [start(expect.any(Function))]]); | ||
expect(hasClosed).toBe(true); | ||
}); | ||
}); | ||
@@ -703,0 +755,0 @@ |
@@ -713,2 +713,3 @@ import { Source, Sink, Operator, SignalKind, TalkbackKind, TalkbackFn } from './types'; | ||
ended = true; | ||
notifierTalkback(TalkbackKind.Close); | ||
sourceTalkback(TalkbackKind.Close); | ||
@@ -715,0 +716,0 @@ sink(SignalKind.End); |
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
222672
5781