@yaas/range
v1.1.0
Published
This is a package that allows you to run either a function a set number of times, and you have the option with `range.cache` to save an array of numbers.
Downloads
4
Readme
Range
This is a package that allows you to run either a function a set number of times, and you have the option with range.cache
to save an array of numbers.
npm install @yaas/range
The normal function range
will not return anything, but will run a callback (if given) the given amount of time.
const range = require('@yaas/range');
console.log(range(1, 5, (i) => console.log(i)));
// => 1
// => 2
// => 3
// => 4
// => 5
// => undefined
And now with range.cache
, it will return an array. In this example, no callback is given, and only returns the array.
const range = require('@yaas/range');
console.log(range.cache(4, 6));
// => [4,5,6]