Socket
Socket
Sign inDemoInstall

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 3.0.0-2.beta to 3.0.0

dist/wonka.es.js.flow

2

package.json
{
"name": "wonka",
"version": "3.0.0-2.beta",
"version": "3.0.0",
"author": "Phil Pluckthun <phil@kitten.sh>",

@@ -5,0 +5,0 @@ "source": "./src/index.js",

@@ -31,4 +31,2 @@ # Wonka

## Why it exists
Reason has been becoming increasingly popular, but it's missing a good pattern for streams that feels native to the language.

@@ -38,4 +36,17 @@ The functional nature of callbags make them a perfect starting point to fix this, and to introduce a reactive programming

Hence `Wonka` is a library that aims to make complex streams of data easy to deal with.
This library also attempts to support as many Reason/JS environments as possible, which makes the adoption of streams across
multiple projects a lot easier. Hence `Wonka` is a library that aims to make complex streams of data easy to deal with.
## Compatibility
`Wonka` is not only compatible with Reason/Bucklescript, but out of the box with other environments as well.
- TypeScript
- JS/Flow
- Reason/OCaml Bucklescript
- Reason/OCaml `bs-native`
- Reason/OCaml Dune
In summary, it should work in any TypeScript/Flow/Reason/OCaml environment with full type safety.
## Installation

@@ -45,4 +56,6 @@

Then add `wonka` to `bs-dependencies` in your `bsconfig.json` file like so:
### BuckleScript
For Bucklescript you will also need to add `wonka` to `bs-dependencies` in your `bsconfig.json` file like so:
```diff

@@ -60,57 +73,6 @@ {

## Getting Started
Writing your first stream is very easy! Let's suppose you would like to create a stream from a list, filter out some values,
then map over the remaining ones, and lastly iterate over the final values.
This can be done with a few operators that might remind you of functions you would also call on iterables.
```reason
let example = [1, 2, 3, 4, 5, 6];
Wonka.fromList(example)
|> Wonka.filter((.x) => x mod 2 === 0)
|> Wonka.map((.x )=> x * 2)
|> Wonka.forEach((.x) => print_endline(string_of_int(x)));
/* prints: 4, 8, 12 */
```
To explain what's going on:
- `fromList` creates a pullable source with values from the list
- `filter` only lets even values through
- `map` multiplies the values by `2`
- `forEach` pulls values from the resulting source and prints them
As you can see, all helpers that we've used are exposed on the `Wonka` module.
But if we would like to use JavaScript-based APIs, then we need to use the `WonkaJs` module.
Let's look at the same example, but instead of a list we will use an `interval` stream.
This stream will output ascending numbers starting from `0` indefinitely.
We will code the same example as before but we'd like the `interval` to push
a new number every `50ms` and to stop after seven values.
```reason
WonkaJs.interval(50)
|> Wonka.take(7)
|> Wonka.filter((.x) => x mod 2 === 0)
|> Wonka.map((.x) => x * 2)
|> Wonka.forEach((.x) => print_endline(string_of_int(x)));
/* prints: 4, 8, 12 */
```
The last three functions stay the same, but we are now using `interval` as our source.
This is a listenable source, meaning that it pushes values downwards when it sees fit.
And the `take` operator tells our source to stop sending values after having received seven
values.
And already you have mastered all the basics of `Wonka` and learned about a couple of its operators!
Go, you! :tada:
## Documentation
I am currently still working on getting some documentation up and running. Those will contain:
This is still a work-in-progress but will contain full information on the following
across all supported languages:

@@ -123,6 +85,1 @@ - The API, i.e. a list of all helpers

Stay tuned and read the signature files in the meantime please:
- [wonka.rei](./src/wonka.rei)
- [wonkaJs.rei](./src/wonka.rei)

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

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

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

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

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

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

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

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

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

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

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

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