Package Exports
- @bramus/range
- @bramus/range/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bramus/range) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Range
Create an array containing a range of elements (cfr. PHP's range)
Installation
npm i @bramus/range
Usage / Example
import { range } from '@bramus/range';
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
const r1 = range(0, 12);
// [7, 8, 9, 10, 11, 12]
const r2 = range(7,12);
// [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
const r3 = range(0, 100, 10);
API
The exposed function has an API identical to PHP's range
method:
range(start, end, step = 1);
Parameters:
start
: First value of the sequence.end
: The sequence is ended upon reaching theend
value.step
(default: 1): If astep
value is given, it will be used as the increment between elements in the sequence.step
should be given as a positive number. If not specified, step will default to1
.
Limitations
Unlike PHP's range
, this function is limited to numbers only. In case you do want to get letters, combine range()
with Array.map()
.
License
@bramus/range
is released under the MIT public license. See the enclosed LICENSE
for details.