RangeCal
A library for calculating ranges
Usage
const Ranges Range PandR RandR = ;const ranges = 0 1;ranges;ranges;
Sample
const Ranges Range PandR RandR = ; // or use it like an es6 module;const ranges1 = 0 1; // create a Ranges instance from Range instance;const ranges2 = 1 19 23 34; // create a Ranges instance from mutiple Range instances;const ranges3 = Ranges; // create a Ranges instance from array;console; // get all of the ranges's total length, it will print 1 to console, because 1 - 0 = 1;console; // get the number of the pieces of ranges, it will print 1 to console;ranges1; // change to [[0, 1], [2, 3]];console; // get all of the ranges's total length, it will print 2 to console, because 3 - 2 + 1 - 0 = 2;console; // get the number of the pieces of ranges, it will print 2 to console;ranges2; // change to [[1, 4], [7, 19], [23, 34]];console; // get all of the ranges's total length, it will print 2 to console, because 34 - 23 + 19 - 7 + 4 - 1 = 26;console; // get the number of the pieces of ranges, it will print 3 to console;console; // convert ranges to string `[[0, 1], [3, 4], [5, 6]]`
License
MIT