fill-range
Fill in a range of numbers or letters, optionally passing an increment or
step
to use, or create a regex-compatible range withoptions.toRegex
Table of Contents
(TOC generated by verb using markdown-toc)
Install
Install with npm:
Install with yarn:
Usage
Expands numbers and letters, optionally using a step
as the last argument. (Numbers may be defined as JavaScript numbers or strings).
Params
from
: {String|Number} the number or letter to start withto
: {String|Number} the number or letter to end withstep
: {String|Number|Object|Function} Optionally pass a step to use.options
: {Object|Function}: See all available options
Examples
By default, an array of values is returned.
Alphabetical ranges
Numerical ranges
Numbers can be defined as actual numbers or strings.
Negative ranges
Numbers can be defined as actual numbers or strings.
Steps (increments)
Options
options.step
Type: number
(formatted as a string or number)
Default: undefined
Description: The increment to use for the range. Can be used with letters or numbers.
Example(s)
options.strictRanges
Type: boolean
Default: false
Description: By default, null
is returned when an invalid range is passed. Enable this option to throw a RangeError
on invalid ranges.
Example(s)
The following are all invalid:
options.stringify
Type: boolean
Default: undefined
Description: Cast all returned values to strings. By default, integers are returned as numbers.
Example(s)
options.toRegex
Type: boolean
Default: undefined
Description: Create a regex-compatible source string, instead of expanding values to an array.
Example(s)
options.transform
Type: function
Default: undefined
Description: Customize each value in the returned array (or string). (you can also pass this function as the last argument to fill()
).
Example(s)
About
Related projects
expand-range: Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… more | homepage
micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | homepage
to-regex-range: Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Contributors
Commits | Contributor |
103 | |
2 | |
1 | |
1 |
Building docs
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
Author
Jon Schlinkert
License
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.5.0, on April 23, 2017.
Last updated