Simple Sorted Arrays for JavaScript
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
SortedArray.js
SortedArray.test.js
package.json

README.md

SortedArray Build Status Gittip

NPM

Install the module with: npm install sortedarray

Browser usage

<script type="text/javascript" src="SortedArray.js"></script>
<script type="text/javascript">
var arr = sortedArray([12, 2, 30, 5, 10]); // <=> new SortedArray([12, 2, 30, 5, 10])
arr.toArray() // [2, 5, 10, 12, 30]

var cursor = arr.add(11);
arr.toArray() // [2, 5, 10, 11, 12, 30]

cursor.before; // 12
cursor.after; // 10

var arr2 = sortedArray(['a','c','b','d'], function compare(a, b){
  return a.charCodeAt(0)-b.charCodeAt(0);
});
arr2.toArray(); // ['a', 'b', 'c', 'd']
arr2.add('e');
arr2.toArray(); // ['a', 'b', 'c', 'd', 'e']
</script>

NodeJS usage

var sortedArray = require('sortedArray');

Release History

v1.0.0 - Initial commit (23 apr. 2012)

Donate

Donate Bitcoins

License

Copyright (c) 2013 Francois-Guillaume Ribreau Licensed under the MIT license.