[Mithril] Fix Stream#map signature (#36910)

* Fix Stream.map signature

* Additional Stream#map test
This commit is contained in:
spacejack 2019-07-16 13:16:22 -04:00 committed by Andrew Branch
parent c58cffffd8
commit 11bce520dd
2 changed files with 8 additions and 3 deletions

View File

@ -5,9 +5,7 @@ declare namespace Stream {
/** Sets the value of the stream. */
(value: T): this;
/** Creates a dependent stream whose value is set to the result of the callback function. */
map(f: (current: T) => Stream<T> | T | void): Stream<T>;
/** Creates a dependent stream whose value is set to the result of the callback function. */
map<U>(f: (current: T) => Stream<U> | U): Stream<U>;
map<U>(f: (current: T) => U): Stream<U>;
/** This method is functionally identical to stream. It exists to conform to Fantasy Land's Applicative specification. */
of(val?: T): Stream<T>;
/** Apply. */

View File

@ -204,6 +204,13 @@ import { Stream } from 'mithril/stream';
console.assert(doubled() === 4);
}
{
const s = stream("a");
const t = s.map(() => 1);
const n = t() + 1;
console.assert(n === 2);
}
// scan
{