What is wonka?
The wonka package is a lightweight but powerful stream library for TypeScript and JavaScript. It allows for the creation, manipulation, and consumption of streams of values over time. It's particularly useful for handling asynchronous operations and events in a functional reactive programming style.
What are wonka's main functionalities?
Creating streams
This feature allows for the creation of streams from various sources. In this example, a stream is created from an array.
import { fromArray } from 'wonka';
const stream = fromArray([1, 2, 3]);
Transforming streams
This feature demonstrates how to transform streams using operators like `map`. In the example, each value in the stream is doubled.
import { fromArray, map } from 'wonka';
const stream = fromArray([1, 2, 3]);
const doubled = map(x => x * 2)(stream);
Consuming streams
This feature shows how to consume streams. The `forEach` operator is used to log each value from the stream to the console.
import { fromArray, forEach } from 'wonka';
const stream = fromArray([1, 2, 3]);
forEach(x => console.log(x))(stream);
Other packages similar to wonka
rxjs
RxJS is a comprehensive library for reactive programming using Observables. It offers a wider range of operators than wonka, making it more powerful but also larger in size. It's well-suited for complex data flow scenarios.
xstream
xstream is a library designed for creating and working with streams of values. It's similar to wonka in its focus on streams but differs in API and operator availability. It's known for its simplicity and small bundle size.
most
Most.js is a high-performance reactive programming library. It focuses on providing a rich set of operators for composing asynchronous and event-based programs. It's known for its speed and efficiency compared to other streaming libraries.
Wonka
A fast push & pull stream library for Reason, loosely following the callbag spec
NOTE: The master
branch currently points to the v4 Release Candidate version!
If you're looking for v3, please check the v3.2.2
“There’s no earthly way of knowing
Which direction we are going
There’s no knowing where we’re rowing
Or which way the river’s flowing” - Willy Wonka
Wonka is a lightweight iterable and observable library loosely based on
the callbag spec. It exposes a set of helpers to create streams,
which are sources of multiple values, which allow you to create, transform
and consume event streams or iterable sets of data.
Wonka is written in Reason, a dialect of OCaml, and can hence be used
for native applications. It is also compiled using BuckleScript to plain
JavaScript and has typings for TypeScript and Flow.
This means that out of the box Wonka is usable in any project that use the following:
- Plain JavaScript
- TypeScript
- Flow
- Reason/OCaml with BuckleScript
- Reason/OCaml with
bs-native
- Reason/OCaml with Dune and Esy
See the documentation at wonka.kitten.sh for more information about using wonka
!
The raw markdown files can be found in this repository in the docs
folder.