evented-array

npm i evented-array

Readme

Evented array Build Status Code Climate

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.

NPM

Jump To

Use