Registry / http-networking / wonka
library0.1.5jsnpmunverified

Wonka is a lightweight, capable push and pull stream library designed for TypeScript and Flow, loosely adhering to the callbag specification. Currently at stable version 6.3.6, it provides a functional approach to handling event streams and iterable data sets, offering helpers to create, transform, and consume multiple values over time. The project maintains an active release cadence, with frequent patch updates addressing minor fixes and improvements, and occasional minor versions introducing new features, such as adding the `addOne` argument to `takeWhile` in `v6.3.0`. Its key differentiators include its small bundle size, strong TypeScript integration, and a focus on composing operations through a `pipe` function, offering a pragmatic alternative to larger reactive programming libraries while maintaining clear stream semantics. Version 6 notably shifted its focus exclusively to TypeScript, Flow, and JavaScript environments, dropping support for Reason/OCaml/esy/dune that was present in v5.

npm install wonka
INSTALL
IMPORT
SIG · WONKA
W
wonka
http-networkingjavascriptv0.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pipe
import { pipe } from 'wonka'
import pipe from 'wonka'
All core utilities and operators are named exports.
fromArray
import { fromArray } from 'wonka'
const fromArray = require('wonka').fromArray;
Wonka v6+ is primarily designed for ESM; while CommonJS might work with transpilation, direct `require` usage can lead to issues in mixed environments.
subscribe
import { subscribe } from 'wonka'
import { Observable } from 'wonka'; new Observable().subscribe();
`subscribe` is a top-level operator in Wonka, not a method on an Observable instance like in some other RxJS-like libraries.
make
import { make } from 'wonka'
import { createSource } from 'wonka'
`make` is the primary low-level function for creating custom observable sources.

Demonstrates creating a stream from an array, applying `filter` and `map` operators, and subscribing. It also shows how to create a custom observable source using `make` with teardown logic for an interval stream.

import { pipe, fromArray, map, filter, subscribe, make } from 'wonka'; // 1. Create a simple stream from an array, transform it, and log values const numberStream = pipe( fromArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), filter(n => n % 2 === 0), // Keep only even numbers map(n => n * 2), // Double them subscribe(value => { console.log(`Array Stream: ${value}`); }) ); // For demonstration, manually unsubscribe after some time (optional for finite streams) // setTimeout(() => numberStream.unsubscribe(), 100); // 2. Create a custom interval stream that emits a few values const intervalSource = (intervalMs: number) => make<number>(({ next, complete }) => { let count = 0; const id = setInterval(() => { if (count < 3) { // Emit 3 values then complete next(count++); } else { complete(); // Signal completion clearInterval(id); } }, intervalMs); return () => clearInterval(id); // Teardown logic }); const intervalPipeline = pipe( intervalSource(1000), // Emit every second map(val => `Custom Interval Stream: ${val}`), subscribe(console.log) ); // The interval stream will automatically complete and clean up after 3 emissions.
Debug
Known issues
breakingVersion 6 of Wonka dropped support for Reason/OCaml/esy/dune. Users migrating from v5 who relied on these environments will need to remain on v5 or rewrite their streaming logic for TypeScript/Flow/JavaScript.
fix
For existing Reason/OCaml projects, consider staying on `wonka@5` or porting stream logic to a JavaScript/TypeScript compatible implementation.
affects: >=6.0.0
breakingIn `v6.2.5`, the `closed` property on `ObservableSubscription`s was made a required boolean field to align with the Observable proposal's type specification. Code expecting `closed` to be optional or `undefined` might encounter TypeScript errors.
fix
Ensure that any custom `ObservableSubscription` implementations or type assertions explicitly define `closed: boolean`. Update any logic that might check for `subscription.closed == null` to `subscription.closed === false` or `subscription.closed === true`.
affects: >=6.2.5
gotchaPrior to `v6.3.4`, there were issues with missing `Symbol.observable` global declarations in typings, which could lead to type errors when integrating with libraries or patterns relying on the TC39 Observable proposal.
fix
Update to `wonka@6.3.4` or higher to resolve missing `Symbol.observable` typings. If unable to update, manually declare `Symbol.observable` globally if necessary for your environment.
affects: <6.3.4
gotchaEarly patch versions of `v6.3` (specifically prior to `v6.3.1`) had missing `declare` keywords on internal ambient enums, causing potential compilation issues in some TypeScript environments.
fix
Update to `wonka@6.3.1` or higher to include the fix for ambient enum declarations.
affects: >=6.3.0 <6.3.1
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use CommonJS `require()` syntax in an environment where Wonka is distributed as an ESM-only package or when the project's `type` is set to `module` in `package.json`.
fix
Switch to ES Module `import` syntax (e.g., `import { pipe } from 'wonka';`). Ensure your project is configured for ESM, or use a bundler that correctly handles module resolution.
Property 'pipe' does not exist on type 'Source<T>'
Misunderstanding Wonka's functional API where `pipe` is a top-level function that composes operations, rather than a method on the source object itself.
fix
Always use `pipe()` as a standalone function: `pipe(source, operator1, operator2, ...)`. Do not try to call `source.pipe()`.
Type 'boolean | undefined' is not assignable to type 'boolean'.
This error can occur in versions `<6.2.5` if you explicitly typed an `ObservableSubscription` and then accessed `closed`, as it was optionally `boolean | undefined`. After `v6.2.5`, `closed` became a required `boolean`.
fix
Update to `wonka@6.2.5` or later. If sticking to older versions, adjust your TypeScript types to explicitly allow `boolean | undefined` for `closed` if you're writing custom subscription logic.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
wonka — npm install wonka · libregistry