Reducible DOM APIs
Small library for dealing with browser DOM events in a reducible style. This lets operate on user events as with regular collection data structures in composable manner.
var open = require"dom-reduce/event"var map = require"reducers/map"var filter = require"reducers/filter"var fold = require"reducers/fold"var takeWhile = require"reducers/take-while"// Take stream of mouse move events.var moves = opendocumentdocumentElement "mousemove"// Map it to the axis positionsvar axis = mapmovesreturn x: eventclientX y: eventclientY// Filter down to the area we're interested in.var lineAxis = filteraxisreturn valuex > 190 && valuex < 200// Take positions only until mouse reaches the edge.// Note that when this contidion is met event listeners// will automatically be removed.var values = takeWhilelineAxisreturn valuey > 0// Drow sowething in the given range.foldlineAxisdrawposition
npm install dom-reduce