m-sorted-array
v1.1.3
Published
Implementation of insert, find and remove of sorted array
Downloads
6
Readme
m-sorted-array
Implementation of insert, find and remove of sorted array
Install
$ npm install --save m-sorted-array
Usage
var SortedArray = require('m-sorted-array');
var SortedArray = require('./lib');
var sortedArray = SortedArray([8, 3, 2, 9, 1]);
console.log(sortedArray.array); // [1, 2, 3, 8, 9]
sortedArray.insert(5);
console.log(sortedArray.array); // [1, 2, 3, 5, 8, 9]
console.log(sortedArray.find(4)); // -1
var strict = false;
console.log(sortedArray.find(4, strict)); // 3
sortedArray.remove(2); // true
sortedArray.remove(2); // false
console.log(sortedArray.array); // [1, 3, 5, 8, 9]
License
Apache-2.0 © Mieszko4