cletus/node_modules/discontinuous-range
2025-05-09 15:53:19 -05:00
..
test Initial commit 2025-05-09 15:53:19 -05:00
.npmignore Initial commit 2025-05-09 15:53:19 -05:00
.travis.yml Initial commit 2025-05-09 15:53:19 -05:00
index.js Initial commit 2025-05-09 15:53:19 -05:00
LICENSE Initial commit 2025-05-09 15:53:19 -05:00
package.json Initial commit 2025-05-09 15:53:19 -05:00
README.md Initial commit 2025-05-09 15:53:19 -05:00

discontinuous-range

DiscontinuousRange(1, 10).subtract(4, 6); // [ 1-3, 7-10 ]

Build Status

this is a pretty simple module, but it exists to service another project so this'll be pretty lacking documentation. reading the test to see how this works may help. otherwise, here's an example that I think pretty much sums it up

###Example

var all_numbers = new DiscontinuousRange(1, 100);
var bad_numbers = DiscontinuousRange(13).add(8).add(60,80);
var good_numbers = all_numbers.clone().subtract(bad_numbers);
console.log(good_numbers.toString()); //[ 1-7, 9-12, 14-59, 81-100 ]
var random_good_number = good_numbers.index(Math.floor(Math.random() * good_numbers.length));