fill-range
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
to-regex-range | 5.0.1 | 7.3 kB | MIT | prod |
The "fill-range" package in JavaScript is a user-friendly tool that is designed to generate an array of alphabetic or numeric sequences. It provides an option to set an increment or 'step' for creating the range and also the capability to create a regex-compatible range by utilizing the options.toRegex
setting.
Utilizing the "fill-range" package is fairly straightforward and can be done in a few steps. First, it needs to be installed in your project with npm using the command $ npm install --save fill-range
.
Once installed, the fill-range function can be required at the top of your file like so: const fill = require('fill-range');
.
The general usage of the fill-range function is fill(from, to[, step, options]);
β where 'from' is the starting point of your range, 'to' is the endpoint, 'step' is the optional increment or decrement level for the range, and 'options' is an object to apply different configuration settings.
Some example usages are:
console.log(fill('1', '10')); // Returns ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
console.log(fill('a', 'e')); // Returns ['a', 'b', 'c', 'd', 'e']
console.log(fill(1, 5)); // Returns [1, 2, 3, 4, 5]
console.log(fill('0', '25', 5)); // Returns ['0', '5', '10', '15', '20', '25'] because it skips by 5 in the range from 0 to 25
console.log(fill('a', 'z', { toRegex: true })); // Returns 'a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z' as a regex-compatible string
The fill-range function is very flexible and allows for a lot of custom functionality using the 'options' argument, such as enabling the options.toRegex
setting to return a regex-compatible source string instead.
The documentation for "fill-range" can be found in the readme content on the fill-range GitHub repository. The readme outlines the basic usage of fill-range, provides example usage code, and discusses the different configuration options available to you. The readme content is the main source of documentation for the "fill-range" package.