Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add initial readme and rename src and package

+76 -40
+21
LICENSE.md
··· 1 + MIT License 2 + 3 + Copyright (c) 2018 Phil Plückthun 4 + 5 + Permission is hereby granted, free of charge, to any person obtaining a copy 6 + of this software and associated documentation files (the "Software"), to deal 7 + in the Software without restriction, including without limitation the rights 8 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 + copies of the Software, and to permit persons to whom the Software is 10 + furnished to do so, subject to the following conditions: 11 + 12 + The above copyright notice and this permission notice shall be included in all 13 + copies or substantial portions of the Software. 14 + 15 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 + SOFTWARE.
+12
README.md
··· 1 + # Wonka 2 + 3 + A fast push & pull stream library for Reason, loosely following the [callbag spec](https://github.com/callbag/callbag) 4 + 5 + > “There’s no earthly way of knowing<br> 6 + > Which direction we are going<br> 7 + > There’s no knowing where we’re rowing<br> 8 + > Or which way the river’s flowing” - **Willy Wonka** 9 + 10 + <br> 11 + 12 + ![Wonka](/docs/wonka.jpg?raw=true)
+27 -27
__tests__/callbag_test.re __tests__/wonka_test.re
··· 1 1 open Jest; 2 - open Callbag_types; 2 + open Wonka_types; 3 3 4 4 let it = test; 5 5 ··· 9 9 open! Expect.Operators; 10 10 11 11 it("sends list items to a puller sink", () => { 12 - let source = Callbag.fromList([10, 20, 30]); 13 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 12 + let source = Wonka.fromList([10, 20, 30]); 13 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 14 14 let signals = [||]; 15 15 16 16 source(signal => { ··· 35 35 open Expect; open! Expect.Operators; 36 36 37 37 it("sends array items to a puller sink", () => { 38 - let source = Callbag.fromArray([| 10, 20, 30 |]); 39 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 38 + let source = Wonka.fromArray([| 10, 20, 30 |]); 39 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 40 40 let signals = ref([||]); 41 41 42 42 source(signal => { ··· 58 58 59 59 it("does not blow up the stack when iterating something huge", () => { 60 60 let arr = Array.make(100000, 123); 61 - let source = Callbag.fromArray(arr); 62 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 61 + let source = Wonka.fromArray(arr); 62 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 63 63 let values = [||]; 64 64 65 65 source(signal => { ··· 88 88 it("maps all emissions of a source", () => { 89 89 let num = ref(1); 90 90 let nums = [||]; 91 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 91 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 92 92 93 - Callbag.map((_) => { 93 + Wonka.map((_) => { 94 94 let res = num^; 95 95 num := num^ + 1; 96 96 res ··· 125 125 it("filters emissions according to a predicate", () => { 126 126 let i = ref(1); 127 127 let nums = [||]; 128 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 128 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 129 129 130 - Callbag.filter(x => x mod 2 === 0, sink => { 130 + Wonka.filter(x => x mod 2 === 0, sink => { 131 131 sink(Start(signal => { 132 132 switch (signal) { 133 133 | Pull => { ··· 162 162 it("folds emissions using an initial seed value", () => { 163 163 let i = ref(1); 164 164 let nums = [||]; 165 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 165 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 166 166 167 - Callbag.scan((acc, x) => acc + x, 0, sink => { 167 + Wonka.scan((acc, x) => acc + x, 0, sink => { 168 168 sink(Start(signal => { 169 169 switch (signal) { 170 170 | Pull => { ··· 198 198 open! Expect.Operators; 199 199 200 200 it("merges different sources into a single one", () => { 201 - let a = Callbag.fromList([1, 2, 3]); 202 - let b = Callbag.fromList([4, 5, 6]); 203 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 201 + let a = Wonka.fromList([1, 2, 3]); 202 + let b = Wonka.fromList([4, 5, 6]); 203 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 204 204 let signals = [||]; 205 - let source = Callbag.merge([| a, b |]); 205 + let source = Wonka.merge([| a, b |]); 206 206 207 207 source(signal => { 208 208 switch (signal) { ··· 226 226 open Expect; 227 227 228 228 it("shares an underlying source with all sinks", () => { 229 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 229 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 230 230 let num = ref(1); 231 231 let nums = [||]; 232 232 233 - let source = Callbag.share(sink => { 233 + let source = Wonka.share(sink => { 234 234 sink(Start(signal => { 235 235 switch (signal) { 236 236 | Pull => { ··· 269 269 open Expect; 270 270 271 271 it("combines the latest values of two sources", () => { 272 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 272 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 273 273 274 274 let makeSource = (factor: int) => { 275 275 let num = ref(1); ··· 290 290 291 291 let sourceA = makeSource(1); 292 292 let sourceB = makeSource(2); 293 - let source = Callbag.combine(sourceA, sourceB); 293 + let source = Wonka.combine(sourceA, sourceB); 294 294 let res = [||]; 295 295 296 296 source(signal => { ··· 311 311 open Expect; 312 312 313 313 it("only lets a maximum number of values through", () => { 314 - let talkback = ref((_: Callbag_types.talkbackT) => ()); 314 + let talkback = ref((_: Wonka_types.talkbackT) => ()); 315 315 let num = ref(1); 316 316 317 - let source = Callbag.take(2, sink => sink(Start(signal => { 317 + let source = Wonka.take(2, sink => sink(Start(signal => { 318 318 switch (signal) { 319 319 | Pull => { 320 320 let i = num^; ··· 364 364 })); 365 365 }; 366 366 367 - Callbag.forEach(x => ignore(Js.Array.push(x, nums)), source); 367 + Wonka.forEach(x => ignore(Js.Array.push(x, nums)), source); 368 368 expect(nums) |> toEqual([| 0, 1, 2, 3 |]) 369 369 }); 370 370 }); ··· 379 379 let actual = [||]; 380 380 381 381 input 382 - |> Callbag.fromArray 383 - |> Callbag.map(x => string_of_int(x)) 384 - |> Callbag.forEach(x => ignore(Js.Array.push(x, actual))); 382 + |> Wonka.fromArray 383 + |> Wonka.map(x => string_of_int(x)) 384 + |> Wonka.forEach(x => ignore(Js.Array.push(x, actual))); 385 385 386 386 expect(output) |> toEqual(output) 387 387 });
+1 -1
bsconfig.json
··· 1 1 // http://bucklescript.github.io/bucklescript/docson/#build-schema.json 2 2 { 3 - "name": "bs-callbag", 3 + "name": "wonka", 4 4 "version": "0.1.0", 5 5 "bsc-flags": ["-bs-super-errors", "-bs-no-version-header"], 6 6 "refmt": 3,
docs/wonka.jpg

This is a binary file and will not be displayed.

+8 -5
package.json
··· 1 1 { 2 - "name": "bs-callbag", 2 + "name": "wonka", 3 3 "version": "0.1.0", 4 4 "scripts": { 5 5 "clean": "bsb -clean-world", ··· 9 9 "test:watch": "jest --watch" 10 10 }, 11 11 "keywords": [ 12 + "wonka", 12 13 "reason", 13 14 "bucklescript", 14 15 "callbag", 16 + "callback", 15 17 "observable", 16 - "iterable" 18 + "iterable", 19 + "stream" 17 20 ], 18 - "repository": "https://github.com/kitten/bs-callbag", 19 - "homepage": "https://github.com/kitten/bs-callbag", 20 - "bugs": "https://github.com/kitten/bs-callbag/issues", 21 + "repository": "https://github.com/kitten/wonka", 22 + "homepage": "https://github.com/kitten/wonka", 23 + "bugs": "https://github.com/kitten/wonka/issues", 21 24 "license": "MIT", 22 25 "devDependencies": { 23 26 "bs-jest": "^0.3.2",
+3 -3
src/callbag.re src/wonka.re
··· 1 - open Callbag_types; 2 - open Callbag_helpers; 1 + open Wonka_types; 2 + open Wonka_helpers; 3 3 4 - module Types = Callbag_types; 4 + module Types = Wonka_types; 5 5 6 6 let fromList = (l, sink) => { 7 7 let restL = ref(l);
+1 -1
src/callbag.rei src/wonka.rei
··· 1 - open Callbag_types; 1 + open Wonka_types; 2 2 3 3 /* -- source factories */ 4 4
+1 -1
src/callbagJs.re src/wonkaJs.re
··· 1 - open Callbag_types; 1 + open Wonka_types; 2 2 3 3 let interval = (p, sink) => { 4 4 let i = ref(0);
+1 -1
src/callbagJs.rei src/wonkaJs.rei
··· 1 - open Callbag_types; 1 + open Wonka_types; 2 2 3 3 /* -- source factories */ 4 4
+1 -1
src/callbag_helpers.re src/wonka_helpers.re
··· 1 - open Callbag_types; 1 + open Wonka_types; 2 2 3 3 let captureTalkback = (source: (signalT('a) => unit) => unit, sinkWithTalkback: [@bs] (signalT('a), talkbackT => unit) => unit) => { 4 4 let talkback = ref((_: talkbackT) => ());
src/callbag_types.re src/wonka_types.re