From f1b66745af557bdb387da32cb2c2318658574ca8 Mon Sep 17 00:00:00 2001 From: spacejack Date: Sat, 25 Mar 2017 01:06:59 -0400 Subject: [PATCH] docs: stream scan and scanMerge (#1719) --- docs/stream.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/stream.md b/docs/stream.md index 250f3365..dc720ef4 100644 --- a/docs/stream.md +++ b/docs/stream.md @@ -5,6 +5,8 @@ - [Static members](#static-members) - [Stream.combine](#streamcombine) - [Stream.merge](#streammerge) + - [Stream.scan](#streamscan) + - [Stream.scanMerge](#streamscanmerge) - [Stream.HALT](#streamhalt) - [Stream["fantasy-land/of"]](#streamfantasy-landof) - [Instance members](#static-members) @@ -114,6 +116,39 @@ Argument | Type | Required | Description --- +##### Stream.scan + +Creates a new stream with the results of calling the function on every value in the stream with an accumulator and the incoming value. + +`stream = Stream.scan(fn, accumulator, stream)` + +Argument | Type | Required | Description +------------- | -------------------------------- | -------- | --- +`fn` | `(accumulator, value) -> result` | Yes | A function that takes an accumulator and value parameter and returns a new accumulator value +`accumulator` | `any` | Yes | The starting value for the accumulator +`stream` | `Stream` | Yes | Stream containing the values +**returns** | `Stream` | | Returns a new stream containing the result + +[How to read signatures](signatures.md) + +--- + +##### Stream.scanMerge + +Takes an array of pairs of streams and scan functions and merges all those streams using the given functions into a single stream. + +`stream = Stream.scanMerge(pairs, accumulator)` + +Argument | Type | Required | Description +------------- | ------------------------------------------------ | -------- | --- +`pairs` | `Array<[Stream, (accumulator, value) -> value]>` | Yes | An array of tuples of stream and scan functions +`accumulator` | `any` | Yes | The starting value for the accumulator +**returns** | `Stream` | | Returns a new stream containing the result + +[How to read signatures](signatures.md) + +--- + ##### Stream.HALT A special value that can be returned to stream callbacks to halt execution of downstreams