import { Stream as MostStream, empty, just, combineArray, combine, flatMap, fromPromise, from } from 'most'
import { sync, SyncSubject, Subject } from 'most-subject'
import { Subscription, StreamOps } from '.'
declare module '.' {
interface S_ {
'MostStream': MostStream
}
}
declare module '../fantasy/typeclasses' {
interface _ {
'MostStream': MostStream
}
}
StreamOps.prototype.empty = empty
StreamOps.prototype.just = just
StreamOps.prototype.scan = function(f, base, fa) {
return fa.scan(f, base)
}
StreamOps.prototype.merge = function(a, b) {
return a.merge(b)
}
StreamOps.prototype.flatMap = function(f, fa) {
return fa.flatMap(f)
}
StreamOps.prototype.filter = function (f: (a: A) => boolean, fa: MostStream): MostStream {
return fa.filter(f)
}
StreamOps.prototype.combine = function (
f: (...a: any[]) => C,
...v: MostStream[]
): MostStream {
return combineArray(f, v)
}
StreamOps.prototype.subject = function () {
return sync()
}
StreamOps.prototype.subscribe = function (fa: MostStream, next: (v: A) => void, complete: () => void) {
return fa.recoverWith(x => {
console.error(x)
return fa
}).subscribe({ next, error: x => console.error(x), complete }) as Subscription
}
StreamOps.prototype.fromPromise = fromPromise;
(StreamOps.prototype.from) = from
export const URI = 'Stream'
export type URI = typeof URI