0.0.1 • Published 10 years ago

scaner v0.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
10 years ago

scaner

Stateful function. Almost like reduce, but for repeated calls to a function instead of elements in a list.

Example

var scaner = require('scaner')

var clickCounter = scaner(0, function (accumilator, current) {
  // Do something with the event (current) that may depend on returned state form last call
  return accumilator + 1
})

document.body.addEventListener('click', clickCounter, false)

To think about

If your accumilator object is any pass by ref value, odd stuff may happend.