evented-array
v2.0.0
Published
Array emitting mutation events
Downloads
10
Readme
Evented array
Just tiny wrapper to make any array emit mutator events.
Use
$ npm install evented-array
var EventedArray = require('evented-array');
var a = new EventedArray(1,2,3);
var b = EventedArray([]);
a.on('shift', function () { console.log('Shifted'); });
b.on('changed', function () { console.log('Changed'); });
a.shift();
b.push(3);
Full list of mutator methods can be found in MDN mutator methods list:
copyWithin
fill
pop
push
reverse
shift
sort
splice
unshift
To subclass Array is used the Irakli Gozalishvili’s method.