export const map = (fn, stream) => sink =>
  stream(value => sink(fn(value)))

export const filter = (fn, stream) => sink =>
  stream(value => {
    if (fn(value)) {
      sink(value)
    }
  })

export const scan = (fn, initial, stream) => sink => {
  let payload = initial
  sink(payload)
  return stream(value => {
    payload = fn(payload, value)
    sink(payload)
  })
}

export const startWith = (initial, stream) => sink => {
  sink(initial)
  return stream(sink)
}

export const flatMap = (fn, stream) => sink =>
  stream(value => fn(value)(sink))

export const fromPromise = promise => sink =>
  promise.then(sink)

@@ -10,11 +10,16 @@
 nst 
-map
+doAction
  = (
@@ -62,24 +62,44 @@
 e =%3E
+ %7B%0A    fn(value)%0A   
  sink(
-fn(
 value)
-)
+%0A  %7D
 )%0A%0Ae
@@ -210,24 +210,401 @@
     %7D%0A  %7D)%0A%0A
+export const flatMap = (fn, stream) =%3E sink =%3E%0A  stream(value =%3E fn(value)(sink))%0A%0Aexport const fromPromise = promise =%3E sink =%3E%0A  promise.then(sink)%0A%0Aexport const fromEvent = (element, event) =%3E sink =%3E %7B%0A  element.addEventListener(event, sink)%0A  return () =%3E element.removeEventListener(sink)%0A%7D%0A%0Aexport const map = (fn, stream) =%3E sink =%3E%0A  stream(value =%3E sink(fn(value)))%0A%0A
 export const
@@ -790,27 +790,27 @@
 st s
-tartWith = (initial
+kipDuplicates = (fn
 , st
@@ -834,164 +834,182 @@
 %7B%0A  
-sink(initial)%0A  return stream(sink)%0A%7D%0A%0Aexport const flatMap =
+let previous = null%0A  return stream(value =%3E %7B%0A    if
  (
+!
 fn
-, stream) =%3E sink =%3E%0A  stream(value =%3E fn(value)(sink))%0A%0Aexport const fromPromise = promise
+(previous, value)) %7B%0A      sink(value)%0A    %7D%0A    previous = value%0A  %7D)%0A%7D%0A%0Aexport const startWith = (initial, stream)
  =%3E 
@@ -1015,30 +1015,52 @@
  sink =%3E
+ %7B
 %0A  
-promise.then
+sink(initial)%0A  return stream
 (sink)%0A
+%7D%0A%0A

Add more functions, reoder