From a011a7e3288247ba48d91993d8443d16f7642d1e Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:45:21 +0530 Subject: [PATCH 01/15] Add documentation for periodic --- rivulet/index.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 91239d1..6168750 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -15,6 +15,21 @@ interface RivuletStream { fold: (accumulator: (accumulated: number, current: number) => number, initial: number) => RivuletStream; } +/** + * Creates a stream that periodically emits `0`, every + * `period` milliseconds. + * + * Marble diagram: + * + * ```text + * periodic(1000) + * ---0---0---0---0---0---... + * ``` + * + * @param {number} period The interval in milliseconds to use as a rate of + * emission. + * @return {RivuletStream} + */ export const periodic: (period: number) => RivuletStream; export const never: () => RivuletStream; export const empty: () => RivuletStream; From 27536c22be1c97e9a192d2d44c82f679a03c5fb1 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:46:30 +0530 Subject: [PATCH 02/15] Add documentation to never --- rivulet/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 6168750..c946eb3 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -31,5 +31,17 @@ interface RivuletStream { * @return {RivuletStream} */ export const periodic: (period: number) => RivuletStream; +/** + * Creates a stream that does nothing when started. It never emits any event. + * + * Marble diagram: + * + * ```text + * never + * ----------------------- + * ``` + * + * @return {RivuletStream} + */ export const never: () => RivuletStream; export const empty: () => RivuletStream; From 2cade04e387aa961c5a2b4fa388756305a88a957 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:47:22 +0530 Subject: [PATCH 03/15] Add documentation for empty --- rivulet/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index c946eb3..7059204 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -44,4 +44,16 @@ export const periodic: (period: number) => RivuletStream; * @return {RivuletStream} */ export const never: () => RivuletStream; +/** + * Creates a stream that immediately emits completes when started, and that's it. + * + * Marble diagram: + * + * ```text + * empty + * -| + * ``` + * + * @return {RivuletStream} + */ export const empty: () => RivuletStream; From ab373d8390e4b8d272b50c7ff301704c4daeebd2 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:50:05 +0530 Subject: [PATCH 04/15] Add documentation for map --- rivulet/index.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 7059204..e507991 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -4,7 +4,24 @@ // Definitions: https://github.com/AmnisIO/packages interface RivuletStream { - map: (mapper: (value: number) => number) => RivuletStream; + /** + * Transforms each event from the input stream through a `project` function, + * to get a stream that emits those transformed events. + * + * Marble diagram: + * + * ```text + * --1---3--5-----7------ + * map(i => i * 10) + * --10--30-50----70----- + * ``` + * + * @param {Function} project A function of type `(value: number) => number` that takes + * a number from the input stream and produces another number, to + * be emitted on the output stream. + * @return {RivuletStream} + */ + map: (project: (value: number) => number) => RivuletStream; mapTo: (value: number) => RivuletStream; filter: (predicate: (value: number) => boolean) => RivuletStream; take: (count: number) => RivuletStream; From d6006f38d094c91a2c98e84ac0bf2491c0766ebc Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:51:25 +0530 Subject: [PATCH 05/15] Add documentation for mapTo --- rivulet/index.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index e507991..b03ac08 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -22,6 +22,22 @@ interface RivuletStream { * @return {RivuletStream} */ map: (project: (value: number) => number) => RivuletStream; + /** + * It's like `map`, but transforms each input to always the same + * constant value on the output stream. + * + * Marble diagram: + * + * ```text + * --1---3--5-----7----- + * mapTo(10) + * --10--10-10----10---- + * ``` + * + * @param value A value to emit on the output stream whenever the + * input stream emits any value. + * @return {RivuletStream} + */ mapTo: (value: number) => RivuletStream; filter: (predicate: (value: number) => boolean) => RivuletStream; take: (count: number) => RivuletStream; From 73e221687896f43fc5af7ba92c6f172e3ab33c41 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:56:43 +0530 Subject: [PATCH 06/15] Add documentation to filter --- rivulet/index.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index b03ac08..53e9d4e 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -39,6 +39,26 @@ interface RivuletStream { * @return {RivuletStream} */ mapTo: (value: number) => RivuletStream; + /** + * Only allows events that pass the test given by the `passes` argument. + * + * Each event from the input stream is given to the `predicate` function. If the + * function returns `true`, the event is forwarded to the output stream, + * otherwise it is ignored and not forwarded. + * + * Marble diagram: + * + * ```text + * --1---2--3-----4-----5---6--7-8-- + * filter(i => i % 2 === 0) + * ------2--------4---------6----8-- + * ``` + * + * @param {Function} predicate A function of type `(value: number) => boolean` that takes + * an event from the input stream and checks if it passes, by returning a + * boolean. + * @return {RivuletStream} + */ filter: (predicate: (value: number) => boolean) => RivuletStream; take: (count: number) => RivuletStream; drop: (count: number) => RivuletStream; From 9a4770c850f5c0937c243e073cf6e06bca0e3700 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:57:39 +0530 Subject: [PATCH 07/15] Add documentation for take --- rivulet/index.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 53e9d4e..5c56a9f 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -60,6 +60,22 @@ interface RivuletStream { * @return {RivuletStream} */ filter: (predicate: (value: number) => boolean) => RivuletStream; + /** + * Lets the first `count` many events from the input stream pass to the + * output stream, then makes the output stream complete. + * + * Marble diagram: + * + * ```text + * --a---b--c----d---e-- + * take(3) + * --a---b--c| + * ``` + * + * @param {number} count How many events to allow from the input stream + * before completing the output stream. + * @return {Stream} + */ take: (count: number) => RivuletStream; drop: (count: number) => RivuletStream; last: () => RivuletStream; From ec81dbcda4dda472d85cc2f770279313e384badd Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:58:19 +0530 Subject: [PATCH 08/15] Add documentation to drop --- rivulet/index.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 5c56a9f..24a21ae 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -74,9 +74,26 @@ interface RivuletStream { * * @param {number} count How many events to allow from the input stream * before completing the output stream. - * @return {Stream} + * @return {RivuletStream} */ take: (count: number) => RivuletStream; + /** + * Ignores the first `count` many events from the input stream, and then + * after that starts forwarding events from the input stream to the output + * stream. + * + * Marble diagram: + * + * ```text + * --a---b--c----d---e-- + * drop(3) + * --------------d---e-- + * ``` + * + * @param {number} count How many events to ignore from the input stream + * before forwarding all events from the input stream to the output stream. + * @return {RivuletStream} + */ drop: (count: number) => RivuletStream; last: () => RivuletStream; sample: (input$: RivuletStream) => RivuletStream; From ca6cd025494d3ab232571a0272023a831d19f437 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sat, 15 Jul 2017 23:58:51 +0530 Subject: [PATCH 09/15] Add documentation for last --- rivulet/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 24a21ae..cd7046c 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -95,6 +95,20 @@ interface RivuletStream { * @return {RivuletStream} */ drop: (count: number) => RivuletStream; + /** + * When the input stream completes, the output stream will emit the last event + * emitted by the input stream, and then will also complete. + * + * Marble diagram: + * + * ```text + * --a---b--c--d----| + * last() + * -----------------d| + * ``` + * + * @return {RivuletStream} + */ last: () => RivuletStream; sample: (input$: RivuletStream) => RivuletStream; delay: (delay: number) => RivuletStream; From 2dec27065d100776286467193971a0acd2c585a9 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:02:41 +0530 Subject: [PATCH 10/15] Add documentation for fold --- rivulet/index.d.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index cd7046c..f34a059 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -112,7 +112,35 @@ interface RivuletStream { last: () => RivuletStream; sample: (input$: RivuletStream) => RivuletStream; delay: (delay: number) => RivuletStream; - fold: (accumulator: (accumulated: number, current: number) => number, initial: number) => RivuletStream; + /** + * "Folds" the stream onto itself. + * + * Combines events from the past throughout the entire execution of the + * input stream, allowing you to accumulate them together. It's essentially + * like `Array.prototype.reduce`. + * + * The output stream starts by emitting the `seed` which you give as argument. + * Then, when an event happens on the input stream, it is combined with that + * seed value through the `accumulate` function, and the output value is + * emitted on the output stream. `fold` remembers that output value as `accumulated`, + * and then when a new input event `value` happens, `accumulated` will be + * combined with that to produce the new `accumulated` and so forth. + * + * Marble diagram: + * + * ```text + * ------1-----1--2----1----1------ + * fold((acc, x) => acc + x, 3) + * 3-----4-----5--7----8----9------ + * ``` + * + * @param {Function} accumulate A function of type `(accumulated: number, value: number) => number` that + * takes the previous accumulated value `accumulated` and the incoming event from the + * input stream and produces the new accumulated value. + * @param seed The initial accumulated value, of type `number`. + * @return {RivuletStream} + */ + fold: (accumulate: (accumulated: number, value: number) => number, seed: number) => RivuletStream; } /** From 7ff9ef70a05894fb47699897ec0857f1272183bd Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:04:56 +0530 Subject: [PATCH 11/15] Add documentation for delay --- rivulet/index.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index f34a059..2892bbd 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -111,7 +111,21 @@ interface RivuletStream { */ last: () => RivuletStream; sample: (input$: RivuletStream) => RivuletStream; - delay: (delay: number) => RivuletStream; + /** + * Delays periodic events by a given time period. + * + * Marble diagram: + * + * ```text + * 1----2--3--4----5| + * delay(60) + * ---1----2--3--4----5| + * ``` + * + * @param {number} period The amount of silence required in milliseconds. + * @return {RivuletStream} + */ + delay: (period: number) => RivuletStream; /** * "Folds" the stream onto itself. * From 3bb194de83f46600b62fc5002b9287b6d09d244c Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:09:02 +0530 Subject: [PATCH 12/15] Add documentation for sample --- rivulet/index.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 2892bbd..8994fc1 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -110,6 +110,23 @@ interface RivuletStream { * @return {RivuletStream} */ last: () => RivuletStream; + /** + * Samples an input stream and emits the latest event from the input stream + * whenever this stream emits an event. + * + * Marble diagram: + * + * ```text + * ----------0----0-| + * sample( + * --a---b--c--d----| + * ) + * ----------c----d-| + * ``` + * + * @param {RivuletStream} input$ The input stream to sample + * @return {RivuletStream} + */ sample: (input$: RivuletStream) => RivuletStream; /** * Delays periodic events by a given time period. From 0734c6560f296d7fdcffe0ff9a754eaef5795fff Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:09:43 +0530 Subject: [PATCH 13/15] Fix version --- rivulet/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivulet/index.d.ts b/rivulet/index.d.ts index 8994fc1..171dc56 100644 --- a/rivulet/index.d.ts +++ b/rivulet/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for rivulet 2.2 +// Type definitions for rivulet 3.0 // Project: https://github.com/AmnisIO/rivulet // Definitions by: Sudarsan Balaji // Definitions: https://github.com/AmnisIO/packages From da4afb1c999213927058ad4a729559aa24bf4949 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:10:35 +0530 Subject: [PATCH 14/15] rivulet v3.0.1 --- rivulet/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivulet/package.json b/rivulet/package.json index 1263dd8..ac59ff6 100644 --- a/rivulet/package.json +++ b/rivulet/package.json @@ -1,6 +1,6 @@ { "name": "@amnisio/rivulet", - "version": "3.0.0", + "version": "3.0.1", "description": "The stream library on which AmnisIO runs", "main": "", "typings": "index.d.ts", From cc1d02a9c631a9b5608617279300c90cccfc6ad6 Mon Sep 17 00:00:00 2001 From: Sudarsan Balaji Date: Sun, 16 Jul 2017 00:11:39 +0530 Subject: [PATCH 15/15] arduino-uno v3.0.1 --- arduino-uno/package-lock.json | 8 ++++---- arduino-uno/package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arduino-uno/package-lock.json b/arduino-uno/package-lock.json index e337af0..a17dba5 100644 --- a/arduino-uno/package-lock.json +++ b/arduino-uno/package-lock.json @@ -1,12 +1,12 @@ { "name": "@amnisio/arduino-uno", - "version": "3.0.0", + "version": "3.0.1", "lockfileVersion": 1, "dependencies": { "@amnisio/rivulet": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@amnisio/rivulet/-/rivulet-3.0.0.tgz", - "integrity": "sha512-M0oH5erSj2JMDLK9K4l7sfZnWwi90QpuNk5O0F0ktlg/rcAB8wtT4UOAGQUc/wHhA+fLy3K7OA0NDR9h0uvM2g==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@amnisio/rivulet/-/rivulet-3.0.1.tgz", + "integrity": "sha512-rIynhwht4LyPbhL/TsIWjDG0YBu6cub2SCuN8/bxz/wdtsD/tEUkTpIWAeq6LjJva9T1m4+KBEoF5v0OQd5guA==" } } } diff --git a/arduino-uno/package.json b/arduino-uno/package.json index c7c46bf..f74fec9 100644 --- a/arduino-uno/package.json +++ b/arduino-uno/package.json @@ -1,12 +1,12 @@ { "name": "@amnisio/arduino-uno", - "version": "3.0.0", + "version": "3.0.1", "description": "The gyrus framework for arduino uno that AmnisIO uses", "main": "", "scripts": {}, "author": "Sudarsan Balaji ", "license": "MIT", "dependencies": { - "@amnisio/rivulet": "3.0.0" + "@amnisio/rivulet": "3.0.1" } }