From bf9905d6637d03b8c358dfe4721c3f5a90c59047 Mon Sep 17 00:00:00 2001 From: RamIdeas Date: Wed, 22 Feb 2017 12:12:18 +0000 Subject: [PATCH 1/2] Added spreadability to `sample` --- type-definitions/most.d.ts | 58 ++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/type-definitions/most.d.ts b/type-definitions/most.d.ts index 68fd1e67..baeee285 100644 --- a/type-definitions/most.d.ts +++ b/type-definitions/most.d.ts @@ -161,23 +161,30 @@ export interface Stream { // Note: Without higher-kinded types, this type cannot be written properly await(): Stream; - sample( - fn: (b: B, c: C) => R, + sample( + fn: (b: B, c: C, ...values: V[]) => R, b: Stream, - c: Stream + c: Stream, + ...streams: Stream[] ): Stream; - sample( - fn: (b: B, c: C, d: D) => R, + sample( + fn: (b: B, c: C, d: D, ...values: V[]) => R, b: Stream, c: Stream, - d: Stream + d: Stream, + ...streams: Stream[] ): Stream; - sample( - fn: (b: B, c: C, d: D, e: E) => R, + sample( + fn: (b: B, c: C, d: D, e: E, ...values: V[]) => R, b: Stream, c: Stream, d: Stream, - e: Stream + e: Stream, + ...streams: Stream[] + ): Stream; + sample( + fn: (...values: V[]) => R, + ...streams: Stream[] ): Stream; sampleWith(sampler: Stream): Stream; @@ -333,35 +340,44 @@ export function delay(dt: number, s: Stream): Stream; export function fromPromise(p: Promise): Stream; export function await(s: Stream>): Stream; -export function sample( - fn: (a: A, b: B) => R, +export function sample( + fn: (a: A, b: B, ...values: V[]) => R, sampler: Stream, a: Stream, - b: Stream + b: Stream, + ...streams: Stream[] ): Stream; -export function sample( - fn: (a: A, b: B, c: C) => R, +export function sample( + fn: (a: A, b: B, c: C, ...values: V[]) => R, sampler: Stream, a: Stream, b: Stream, - c: Stream + c: Stream, + ...streams: Stream[] ): Stream; -export function sample( - fn: (a: A, b: B, c: C, d: D) => R, +export function sample( + fn: (a: A, b: B, c: C, d: D, ...values: V[]) => R, sampler: Stream, a: Stream, b: Stream, c: Stream, - d: Stream + d: Stream, + ...streams: Stream[] ): Stream; -export function sample( - fn: (a: A, b: B, c: C, d: D, e: E) => R, +export function sample( + fn: (a: A, b: B, c: C, d: D, e: E, ...values: V[]) => R, sampler: Stream, a: Stream, b: Stream, c: Stream, d: Stream, - e: Stream + e: Stream, + ...streams: Stream[] +): Stream; +export function sample( + fn: (...values: V[]) => R, + sampler: Stream, + ...streams: Stream[] ): Stream; export function sampleWith(sampler: Stream, s: Stream): Stream; From c976607a181841c750a4bb27d73dddac993de4de Mon Sep 17 00:00:00 2001 From: RamIdeas Date: Wed, 22 Feb 2017 12:29:43 +0000 Subject: [PATCH 2/2] Added overloads for 1 (or more) sampled streams --- type-definitions/most.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/type-definitions/most.d.ts b/type-definitions/most.d.ts index baeee285..42895be4 100644 --- a/type-definitions/most.d.ts +++ b/type-definitions/most.d.ts @@ -161,6 +161,11 @@ export interface Stream { // Note: Without higher-kinded types, this type cannot be written properly await(): Stream; + sample( + fn: (b: B, ...values: V[]) => R, + b: Stream, + ...streams: Stream[] + ): Stream; sample( fn: (b: B, c: C, ...values: V[]) => R, b: Stream, @@ -340,6 +345,12 @@ export function delay(dt: number, s: Stream): Stream; export function fromPromise(p: Promise): Stream; export function await(s: Stream>): Stream; +export function sample( + fn: (a: A, ...values: V[]) => R, + sampler: Stream, + a: Stream, + ...streams: Stream[] +): Stream; export function sample( fn: (a: A, b: B, ...values: V[]) => R, sampler: Stream,