From 70bf37cba6da26cd616d069789504f691390d7d6 Mon Sep 17 00:00:00 2001 From: pixelmike Date: Sat, 25 Feb 2017 18:34:32 -0500 Subject: [PATCH] Add stream/scan, scanMerge types --- mithril.d.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mithril.d.ts b/mithril.d.ts index 37179e16..8864d60a 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -238,6 +238,18 @@ declare namespace Mithril { /** A special value that can be returned to stream callbacks to halt execution of downstreams. */ HALT: any; } + + interface StreamScan { + /** Creates a new stream with the results of calling the function on every incoming stream with and accumulator and the incoming value. */ + (fn: (acc: U, value: T) => U, acc: U, stream: Stream): Stream; + } + + interface StreamScanMerge { + /** Takes an array of pairs of streams and scan functions and merges all those streams using the given functions into a single stream. */ + (pairs: [Stream, (acc: U, value: T) => U][], acc: U): Stream; + /** Takes an array of pairs of streams and scan functions and merges all those streams using the given functions into a single stream. */ + (pairs: [Stream, (acc: U, value: any) => U][], acc: U): Stream; + } } declare module 'mithril' { @@ -284,3 +296,13 @@ declare module 'mithril/stream' { const s: Mithril.StreamFactory; export = s; } + +declare module 'mithril/stream/scan' { + const s: Mithril.StreamScan; + export = s; +} + +declare module 'mithril/stream/scanMerge' { + const sm: Mithril.StreamScanMerge; + export = sm; +}