Comparing version 6.1.0 to 6.1.1
@@ -529,3 +529,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var observableSymbol = () => Symbol.observable || (Symbol.observable = Symbol("observable")); | ||
var observableSymbol = () => Symbol.observable || "@@observable"; | ||
@@ -532,0 +532,0 @@ exports.buffer = function buffer(r) { |
{ | ||
"name": "wonka", | ||
"description": "A tiny but capable push & pull stream library for TypeScript and Flow", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -17,4 +17,3 @@ "source": "./src/index.ts", | ||
}, | ||
"./package.json": "./package.json", | ||
"./": "./" | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -40,3 +39,3 @@ "sideEffects": false, | ||
"scripts": { | ||
"test": "jest", | ||
"test": "vitest run", | ||
"check": "tsc", | ||
@@ -74,8 +73,2 @@ "lint": "eslint --ext=js,ts .", | ||
}, | ||
"jest": { | ||
"testRegex": "(src/.*(\\.|/)(test|spec))\\.ts$", | ||
"transform": { | ||
"^.+\\.tsx?$": "@sucrase/jest-plugin" | ||
} | ||
}, | ||
"dependencies": {}, | ||
@@ -88,5 +81,2 @@ "devDependencies": { | ||
"@rollup/pluginutils": "^4.2.1", | ||
"@sucrase/jest-plugin": "^2.2.1", | ||
"@types/jest": "^28.1.6", | ||
"@types/node": "^18.7.2", | ||
"@types/zen-observable": "^0.8.3", | ||
@@ -100,3 +90,2 @@ "@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-jest": "^26.8.2", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
@@ -106,3 +95,2 @@ "flowgen": "^1.20.1", | ||
"husky-v4": "^4.3.8", | ||
"jest": "^28.1.3", | ||
"lint-staged": "^13.0.3", | ||
@@ -116,4 +104,5 @@ "npm-run-all": "^4.1.5", | ||
"typescript": "^4.8.2", | ||
"vitest": "^0.23.4", | ||
"zen-observable": "^0.8.15" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
import { Source } from '../types'; | ||
@@ -17,3 +19,3 @@ import { fromValue, makeSubject } from '../sources'; | ||
beforeEach(() => { | ||
jest.useFakeTimers(); | ||
vi.useFakeTimers(); | ||
}); | ||
@@ -34,3 +36,3 @@ | ||
const { source: sourceB, next: nextB } = makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -50,3 +52,3 @@ const combined = combine(sourceA, sourceB); | ||
const { source: sourceC, next: nextC } = makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -67,3 +69,3 @@ const combined = zip([sourceA, sourceB, sourceC]); | ||
const { source: sourceB, next: nextB } = makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -70,0 +72,0 @@ const combined = zip({ a: sourceA, b: sourceB }); |
@@ -0,1 +1,3 @@ | ||
import { it, expect, vi } from 'vitest'; | ||
import { Source, Sink, Operator, Signal, SignalKind, TalkbackKind, TalkbackFn } from '../types'; | ||
@@ -44,3 +46,3 @@ import { push, start } from '../helpers'; | ||
talkback!(TalkbackKind.Pull); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(values).toEqual([output]); | ||
@@ -86,3 +88,3 @@ }); | ||
sink!(push(0)); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(values).toEqual([result]); | ||
@@ -129,3 +131,3 @@ // Subsequently the Pull signal should have travelled upwards | ||
talkback!(TalkbackKind.Pull); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(closing).toBe(1); | ||
@@ -176,3 +178,3 @@ }); | ||
talkback!(TalkbackKind.Pull); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(ending).toBe(1); | ||
@@ -228,3 +230,3 @@ expect(signals).toEqual([push(result), SignalKind.End]); | ||
talkback!(TalkbackKind.Pull); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(ending).toBe(1); | ||
@@ -296,3 +298,3 @@ expect(pulls).toBe(3); | ||
// The Push signal should've been dropped | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(signals).toEqual([SignalKind.End]); | ||
@@ -328,3 +330,3 @@ expect(pulls).toBe(1); | ||
// The Push signal should've been dropped | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(signals).toEqual([]); | ||
@@ -405,5 +407,5 @@ }); | ||
expect(signals.length).toBe(0); | ||
jest.advanceTimersByTime(5); | ||
vi.advanceTimersByTime(5); | ||
expect(hasPushed).toBeTruthy(); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
@@ -410,0 +412,0 @@ expect(signals).toEqual([push(result), SignalKind.End]); |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
import { Source, Sink, Signal, SignalKind, TalkbackKind, TalkbackFn } from '../types'; | ||
@@ -21,3 +23,3 @@ import { push, start } from '../helpers'; | ||
beforeEach(() => { | ||
jest.useFakeTimers(); | ||
vi.useFakeTimers(); | ||
}); | ||
@@ -45,3 +47,3 @@ | ||
const { source: input$, next } = sources.makeSubject(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -76,3 +78,3 @@ sinks.forEach(fn)(operators.buffer(notifier$)(input$)); | ||
const { source, next, complete } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -99,3 +101,3 @@ operators.concatMap((x: number) => sources.fromArray([x, x + 1]))(source)(fn); | ||
const signals: Signal<any>[] = []; | ||
const teardown = jest.fn(); | ||
const teardown = vi.fn(); | ||
const fn = (signal: Signal<any>) => { | ||
@@ -120,3 +122,3 @@ signals.push(signal); | ||
const source = operators.delay<number>(4)(sources.fromArray([1, 10])); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -129,6 +131,6 @@ sinks.forEach(fn)( | ||
jest.advanceTimersByTime(14); | ||
vi.advanceTimersByTime(14); | ||
expect(fn.mock.calls).toEqual([[1], [2]]); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(fn.mock.calls).toEqual([[1], [2], [10], [20]]); | ||
@@ -138,3 +140,3 @@ }); | ||
it('works for fully asynchronous sources', () => { | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -150,3 +152,3 @@ sinks.forEach(fn)( | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(fn).toHaveBeenCalledWith(1); | ||
@@ -178,3 +180,3 @@ }); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -184,10 +186,10 @@ sinks.forEach(fn)(operators.debounce(() => 100)(source)); | ||
next(1); | ||
jest.advanceTimersByTime(50); | ||
vi.advanceTimersByTime(50); | ||
expect(fn).not.toHaveBeenCalled(); | ||
next(2); | ||
jest.advanceTimersByTime(99); | ||
vi.advanceTimersByTime(99); | ||
expect(fn).not.toHaveBeenCalled(); | ||
jest.advanceTimersByTime(1); | ||
vi.advanceTimersByTime(1); | ||
expect(fn).toHaveBeenCalledWith(2); | ||
@@ -198,3 +200,3 @@ }); | ||
const { source, next, complete } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -205,3 +207,3 @@ sinks.forEach(fn)(operators.debounce(() => 100)(source)); | ||
complete(); | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(fn).toHaveBeenCalled(); | ||
@@ -222,3 +224,3 @@ }); | ||
const { source, next } = sources.makeSubject(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -230,3 +232,3 @@ sinks.forEach(fn)(operators.delay(100)(source)); | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(fn).toHaveBeenCalledWith(1); | ||
@@ -247,3 +249,3 @@ }); | ||
const { source, next } = sources.makeSubject(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -271,3 +273,3 @@ sinks.forEach(fn)(operators.filter(x => !!x)(source)); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -294,3 +296,3 @@ sinks.forEach(fn)(operators.map((x: number) => x + 1)(source)); | ||
const { source, next, complete } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -316,3 +318,3 @@ operators.mergeMap((x: number) => sources.fromArray([x, x + 1]))(source)(fn); | ||
const values: Signal<any>[] = []; | ||
const teardown = jest.fn(); | ||
const teardown = vi.fn(); | ||
const fn = (signal: Signal<any>) => { | ||
@@ -337,3 +339,3 @@ values.push(signal); | ||
const source = operators.delay<number>(4)(sources.fromArray([1, 10])); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -346,3 +348,3 @@ sinks.forEach(fn)( | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(fn.mock.calls).toEqual([[1], [10], [2], [20]]); | ||
@@ -374,3 +376,3 @@ }); | ||
const { source, next, complete } = sources.makeSubject<any>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -399,3 +401,3 @@ sinks.forEach(() => {})(operators.onEnd(fn)(source)); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -427,3 +429,3 @@ sinks.forEach(() => {})(operators.onPush(fn)(source)); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
const source: Source<any> = _sink => { | ||
@@ -462,3 +464,3 @@ sink = _sink; | ||
const { source: input$, next } = sources.makeSubject(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -487,3 +489,3 @@ sinks.forEach(fn)(operators.sample(notifier$)(input$)); | ||
const { source: input$, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -521,4 +523,4 @@ const reducer = (acc: number, x: number) => acc + x; | ||
const fnA = jest.fn(); | ||
const fnB = jest.fn(); | ||
const fnA = vi.fn(); | ||
const fnB = vi.fn(); | ||
@@ -546,3 +548,3 @@ sinks.forEach(fnA)(source); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -571,3 +573,3 @@ sinks.forEach(fn)(operators.skip(1)(source)); | ||
const { source: input$, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -595,3 +597,3 @@ sinks.forEach(fn)(operators.skipUntil(notifier$)(input$)); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -620,3 +622,3 @@ sinks.forEach(fn)(operators.skipWhile((x: any) => x <= 1)(source)); | ||
const { source, next, complete } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -643,3 +645,3 @@ operators.switchMap((x: number) => sources.fromArray([x, x + 1]))(source)(fn); | ||
const signals: Signal<any>[] = []; | ||
const teardown = jest.fn(); | ||
const teardown = vi.fn(); | ||
const fn = (signal: Signal<any>) => { | ||
@@ -664,3 +666,3 @@ signals.push(signal); | ||
const source = operators.delay<number>(4)(sources.fromArray([1, 10])); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -673,3 +675,3 @@ sinks.forEach(fn)( | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(fn.mock.calls).toEqual([[1], [10], [20]]); | ||
@@ -693,3 +695,3 @@ }); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -720,3 +722,3 @@ operators.take(1)(source)(fn); | ||
const { source: input$, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -749,3 +751,3 @@ operators.takeUntil(notifier$)(input$)(fn); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -801,3 +803,3 @@ operators.takeWhile((x: any) => x < 2)(source)(fn); | ||
const { source, next } = sources.makeSubject<number>(); | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -808,7 +810,7 @@ sinks.forEach(fn)(operators.throttle(() => 100)(source)); | ||
expect(fn).toHaveBeenCalledWith(1); | ||
jest.advanceTimersByTime(50); | ||
vi.advanceTimersByTime(50); | ||
next(2); | ||
expect(fn).toHaveBeenCalledTimes(1); | ||
jest.advanceTimersByTime(50); | ||
vi.advanceTimersByTime(50); | ||
@@ -815,0 +817,0 @@ next(3); |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import { Source, Sink, SignalKind, TalkbackKind } from '../types'; | ||
@@ -16,3 +18,3 @@ import { push, start } from '../helpers'; | ||
let pulls = 0; | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -90,3 +92,3 @@ const source: Source<any> = sink => { | ||
it('ignores Push signals after the source has ended', () => { | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
const source: Source<any> = sink => { | ||
@@ -108,3 +110,3 @@ sink( | ||
it('ignores Push signals after cancellation', () => { | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
const source: Source<any> = sink => { | ||
@@ -212,3 +214,3 @@ sink( | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
const promise = sinks.toPromise(source).then(fn); | ||
@@ -228,3 +230,3 @@ | ||
it('creates a Promise for synchronous sources', async () => { | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
await sinks.toPromise(sources.fromArray([1, 2, 3])).then(fn); | ||
@@ -237,4 +239,4 @@ expect(fn).toHaveBeenCalledWith(3); | ||
it('creates an Observable mirroring the Wonka source', () => { | ||
const next = jest.fn(); | ||
const complete = jest.fn(); | ||
const next = vi.fn(); | ||
const complete = vi.fn(); | ||
let pulls = 0; | ||
@@ -285,3 +287,3 @@ let sink: Sink<any> | null = null; | ||
it('creates a Callbag mirroring the Wonka source', () => { | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
let pulls = 0; | ||
@@ -311,3 +313,3 @@ let sink: Sink<any> | null = null; | ||
let ending = 0; | ||
const fn = jest.fn(); | ||
const fn = vi.fn(); | ||
@@ -314,0 +316,0 @@ const source: Source<any> = sink => |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect, beforeEach, vi } from 'vitest'; | ||
import { Source, Sink, Signal, SignalKind, TalkbackKind, TalkbackFn } from '../types'; | ||
@@ -73,3 +75,3 @@ import { push, start, talkbackPlaceholder } from '../helpers'; | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(pushes).toBe(1); | ||
@@ -109,3 +111,3 @@ }); | ||
beforeEach(() => { | ||
jest.useFakeTimers(); | ||
vi.useFakeTimers(); | ||
}); | ||
@@ -145,3 +147,3 @@ | ||
it('correctly merges hot sources', () => { | ||
const onStart = jest.fn(); | ||
const onStart = vi.fn(); | ||
const source = operators.merge<any>([ | ||
@@ -159,5 +161,5 @@ operators.onStart(onStart)(sources.never), | ||
it('correctly merges asynchronous sources', () => { | ||
jest.useFakeTimers(); | ||
vi.useFakeTimers(); | ||
const onStart = jest.fn(); | ||
const onStart = vi.fn(); | ||
const source = operators.merge<any>([ | ||
@@ -169,3 +171,3 @@ operators.onStart(onStart)(sources.fromValue(-1)), | ||
const signals = collectSignals(source); | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(onStart).toHaveBeenCalledTimes(2); | ||
@@ -198,3 +200,3 @@ | ||
it('may be used to create async sources', () => { | ||
const teardown = jest.fn(); | ||
const teardown = vi.fn(); | ||
const source = sources.make(observer => { | ||
@@ -208,3 +210,3 @@ setTimeout(() => observer.next(1), 10); | ||
expect(signals).toEqual([start(expect.any(Function))]); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
@@ -215,3 +217,3 @@ expect(signals).toEqual([start(expect.any(Function)), push(1), SignalKind.End]); | ||
it('supports active cancellation', () => { | ||
const teardown = jest.fn(); | ||
const teardown = vi.fn(); | ||
const source = sources.make(() => teardown); | ||
@@ -227,3 +229,3 @@ | ||
expect(teardown).not.toHaveBeenCalled(); | ||
jest.runAllTimers(); | ||
vi.runAllTimers(); | ||
expect(teardown).toHaveBeenCalled(); | ||
@@ -296,3 +298,3 @@ }); | ||
beforeEach(() => { | ||
jest.useRealTimers(); | ||
vi.useRealTimers(); | ||
}); | ||
@@ -358,9 +360,9 @@ | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(pushes).toBe(1); | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(pushes).toBe(2); | ||
talkback!(TalkbackKind.Close); | ||
jest.advanceTimersByTime(100); | ||
vi.advanceTimersByTime(100); | ||
expect(pushes).toBe(2); | ||
@@ -375,4 +377,4 @@ }); | ||
const element = { | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
addEventListener: vi.fn(), | ||
removeEventListener: vi.fn(), | ||
}; | ||
@@ -379,0 +381,0 @@ |
@@ -19,4 +19,3 @@ import { Source, SignalKind, TalkbackKind } from './types'; | ||
const observableSymbol = (): symbol => | ||
(Symbol as any).observable || ((Symbol as any).observable = Symbol('observable')); | ||
const observableSymbol = (): symbol | string => Symbol.observable || '@@observable'; | ||
@@ -23,0 +22,0 @@ export function fromObservable<T>(input: Observable<T>): Source<T> { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27
5737
221210