UNPKG

kefir

Version:

Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage

26 lines (19 loc) 432 B
import {createStream, createProperty} from '../patterns/one-source' const mixin = { _init({fn}) { this._fn = fn }, _free() { this._fn = null }, _handleValue(x) { const fn = this._fn this._emitValue(fn(x)) }, } const S = createStream('map', mixin) const P = createProperty('map', mixin) const id = x => x export default function map(obs, fn = id) { return new (obs._ofSameType(S, P))(obs, {fn}) }