Skip to content

Commit a6d1c37

Browse files
committed
feat: restrict the return type to streams
1 parent d175d90 commit a6d1c37

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/create.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ export const test: Test = describe(`create`, [
1919
return promise.then(equal(values))
2020
}),
2121

22-
given(`(Stream<A>) => B`, [
23-
it(`returns [Sink<A>, B]`, ({ equal }) => {
22+
given(`(Stream<A>) => Stream<B>`, [
23+
it(`returns [Sink<A>, Stream<B>]`, ({ equal }) => {
2424
const values = [1, 2, 3]
2525
const scheduler = newDefaultScheduler()
26-
const [sink, promise] = create((stream: Stream<number>) =>
27-
collectEvents<number>(scheduler, stream)
28-
)
26+
const [sink, stream] = create()
2927

30-
values.forEach(n => sink.event(currentTime(scheduler), n))
31-
sink.end(currentTime(scheduler))
28+
setTimeout(function() {
29+
values.forEach(n => sink.event(currentTime(scheduler), n))
30+
sink.end(currentTime(scheduler))
31+
}, 0)
3232

33-
return promise.then(equal(values))
33+
return collectEvents(scheduler, stream).then(equal(values))
3434
}),
3535
]),
3636

src/create.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { id } from '@most/prelude'
66
export function create<A = any>(): [AttachSink<A>, Stream<A>]
77
export function create<A, B>(f: (stream: Stream<A>) => B): [AttachSink<A>, B]
88

9-
export function create<A, B = Stream<A>>(
10-
f: (stream: Stream<A>) => B = id as (stream: Stream<A>) => B
11-
): [AttachSink<A>, B] {
12-
const source = new ProxyStream()
9+
export function create<A, B = A>(
10+
f: (stream: Stream<A>) => Stream<B> = id as (stream: Stream<A>) => Stream<B>
11+
): [AttachSink<A>, Stream<B>] {
12+
const source = new ProxyStream<A>()
1313

1414
return [source, f(source)]
1515
}

0 commit comments

Comments
 (0)