1.1.6 • Published 7 years ago
zo-containers-js v1.1.6
containers
Some utility containers: BitArray, OrderedArray
- npm install zo-containers-js --save
BitArray
const { BitArray } = require('zo-containers-js');
let ba = new BitArray(8);
ba.set(5, 1);
ba.get(5); //1
let entries = ba.entries();
for (let [i, v] of entries) {
//...
}
OrderedArray
const { OrderedArray } = require('zo-containers-js');
let oa = new OrderedArray((a, b) => a - b);
oa.add(6);
oa.add(8);
oa.add(2);
oa.add(3);
console.log(oa); // [ 2, 3, 6, 8 ]
let oa2 = new OrderedArray((a, b) => a - b);
oa2.add(5);
oa2.add(3);
oa.merge(oa2);
console.log(oa); // [ 2, 3, 3, 5, 6, 8 ]