Skip to content

Commit

Permalink
feat: default to id function
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS committed Sep 25, 2017
1 parent e8fb376 commit d175d90
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/create.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AttachSink } from './types'
import { ProxyStream } from './ProxyStream'
import { Stream } from '@most/types'
import { id } from '@most/prelude'

export function create<A = any>(): [AttachSink<A>, Stream<A>]
export function create<A, B>(f: (stream: Stream<A>) => B): [AttachSink<A>, B]

export function create<A, B = Stream<A>>(
f?: (stream: Stream<A>) => B
f: (stream: Stream<A>) => B = id as (stream: Stream<A>) => B
): [AttachSink<A>, B] {
const source = new ProxyStream()

return [source, f === void 0 ? (source as any) as B : f(source)]
return [source, f(source)]
}

0 comments on commit d175d90

Please sign in to comment.