A range function for JavaScript. See docs.
⚠️ Depending on your environment, the code may requireregeneratorRuntimeto be defined, for instance by importing regenerator-runtime/runtime.
import{range}from'@iterable-iterator/range';range(3);// 0 1 2range(2,5);// 2 3 4range(5,2,-1);// 5 4 3range(Number.MAX_SAFE_INTEGER).has(1234);// truerange(0,10,2).get(3);// 6// If you only use the iterator feature you can save bytes by calling the// IterableIterator function directlyimport{forwardRangeIterator,backwardRangeIterator}from'@iterable-iterator/range';for(constxofforwardRangeIterator(0,10,1)) ... for(constxofbackwardRangeIterator(10,0,-1)) ... // caveat: This requires you to specify all parameters, and choose the correct// implementation depending on the sign of the `step` parameter.// For convenience, rangeIterator will return the correct kind of// IterableIterator without constructing a Range object. It has the same signature// as the range function.import{rangeIteratorasrange}from'@iterable-iterator/range';