2.0.2 • Published 7 years ago

rul v2.0.2

Weekly downloads
5
License
Apache-2.0
Repository
github
Last release
7 years ago

Remotely Updated List Build Status Coverage Status

Rul provides an abstraction layer above any list-like object, making it possible to control several different lists with a single unified interface. This can be achieved by consuming a rul:

var Rul = require('rul'),
    rul = new Rul();

// ...

rul.consume(
  function onAdd(elem,index){ /***/ },
  function onRemove(index,ammount){ /***/ },
  function onMove(lowerIndex,higherIndex){ /***/ }
);

What follows is an example of modifying a rul:

rul.add(0);
rul.clear();
rul.append([1,2,3,4,5,6,7]);
rul.add(4);
rul.replace(rul.length - 1,3);
rul.remove(1,2);
rul.move(2,4);
rul.swap(1,3);

// final state:
// [1, 7, 6, 4, 5, 3]

Above methods are available on any Rul instance. Some accessor methods are available too:

rul.indexOf(elem);
rul.lastIndexOf(elem);
rul.get(index);

for(value of rul){
  //...
}

These methods will only work on consumable ruls. A rul can become non-consumable if it was initialized as volatile (true as the only argument of the constructor) and has recently been consumed. Volatile ruls exist purely for the sake of memory management: when they become non-consumable they behave as sinks of data, it's up to the consumers to decide what to do with it, but the rul itself won't retain said data.

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago