update, text, response
This commit is contained in:
2
node_modules/fill-range/LICENSE
generated
vendored
2
node_modules/fill-range/LICENSE
generated
vendored
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-present, Jon Schlinkert.
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
111
node_modules/fill-range/README.md
generated
vendored
111
node_modules/fill-range/README.md
generated
vendored
@@ -1,8 +1,21 @@
|
||||
# fill-range [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [](https://www.npmjs.com/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://travis-ci.org/jonschlinkert/fill-range)
|
||||
# fill-range [](https://www.npmjs.com/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://npmjs.org/package/fill-range) [](https://travis-ci.org/jonschlinkert/fill-range)
|
||||
|
||||
> Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`
|
||||
|
||||
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||
## Table of Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Examples](#examples)
|
||||
- [Options](#options)
|
||||
* [options.step](#optionsstep)
|
||||
* [options.strictRanges](#optionsstrictranges)
|
||||
* [options.stringify](#optionsstringify)
|
||||
* [options.toRegex](#optionstoregex)
|
||||
* [options.transform](#optionstransform)
|
||||
- [About](#about)
|
||||
|
||||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
|
||||
|
||||
## Install
|
||||
|
||||
@@ -12,16 +25,23 @@ Install with [npm](https://www.npmjs.com/):
|
||||
$ npm install --save fill-range
|
||||
```
|
||||
|
||||
Install with [yarn](https://yarnpkg.com):
|
||||
|
||||
```sh
|
||||
$ yarn add fill-range
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Expands numbers and letters, optionally using a `step` as the last argument. _(Numbers may be defined as JavaScript numbers or strings)_.
|
||||
|
||||
```js
|
||||
const fill = require('fill-range');
|
||||
// fill(from, to[, step, options]);
|
||||
var fill = require('fill-range');
|
||||
fill(from, to[, step, options]);
|
||||
|
||||
console.log(fill('1', '10')); //=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
|
||||
console.log(fill('1', '10', { toRegex: true })); //=> [1-9]|10
|
||||
// examples
|
||||
console.log(fill('1', '10')); //=> '[ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ]'
|
||||
console.log(fill('1', '10', {toRegex: true})); //=> [1-9]|10
|
||||
```
|
||||
|
||||
**Params**
|
||||
@@ -128,7 +148,7 @@ fill(1, 10, 'foo'); // invalid "step" argument
|
||||
|
||||
```js
|
||||
console.log(fill(1, 5)); //=> [ 1, 2, 3, 4, 5 ]
|
||||
console.log(fill(1, 5, { stringify: true })); //=> [ '1', '2', '3', '4', '5' ]
|
||||
console.log(fill(1, 5, {stringify: true})); //=> [ '1', '2', '3', '4', '5' ]
|
||||
```
|
||||
|
||||
### options.toRegex
|
||||
@@ -143,13 +163,13 @@ console.log(fill(1, 5, { stringify: true })); //=> [ '1', '2', '3', '4', '5' ]
|
||||
|
||||
```js
|
||||
// alphabetical range
|
||||
console.log(fill('a', 'e', { toRegex: true })); //=> '[a-e]'
|
||||
console.log(fill('a', 'e', {toRegex: true})); //=> '[a-e]'
|
||||
// alphabetical with step
|
||||
console.log(fill('a', 'z', 3, { toRegex: true })); //=> 'a|d|g|j|m|p|s|v|y'
|
||||
console.log(fill('a', 'z', 3, {toRegex: true})); //=> 'a|d|g|j|m|p|s|v|y'
|
||||
// numerical range
|
||||
console.log(fill('1', '100', { toRegex: true })); //=> '[1-9]|[1-9][0-9]|100'
|
||||
console.log(fill('1', '100', {toRegex: true})); //=> '[1-9]|[1-9][0-9]|100'
|
||||
// numerical range with zero padding
|
||||
console.log(fill('000001', '100000', { toRegex: true }));
|
||||
console.log(fill('000001', '100000', {toRegex: true}));
|
||||
//=> '0{5}[1-9]|0{4}[1-9][0-9]|0{3}[1-9][0-9]{2}|0{2}[1-9][0-9]{3}|0[1-9][0-9]{4}|100000'
|
||||
```
|
||||
|
||||
@@ -164,33 +184,38 @@ console.log(fill('000001', '100000', { toRegex: true }));
|
||||
**Example(s)**
|
||||
|
||||
```js
|
||||
// add zero padding
|
||||
console.log(fill(1, 5, value => String(value).padStart(4, '0')));
|
||||
// increase padding by two
|
||||
var arr = fill('01', '05', function(val, a, b, step, idx, arr, options) {
|
||||
return repeat('0', (options.maxLength + 2) - val.length) + val;
|
||||
});
|
||||
|
||||
console.log(arr);
|
||||
//=> ['0001', '0002', '0003', '0004', '0005']
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
### Related projects
|
||||
|
||||
* [braces](https://www.npmjs.com/package/braces): Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces) | [homepage](https://github.com/jonschlinkert/braces "Fast, comprehensive, bash-like brace expansion implemented in JavaScript. Complete support for the Bash 4.3 braces specification, without sacrificing speed.")
|
||||
* [expand-range](https://www.npmjs.com/package/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range) | [homepage](https://github.com/jonschlinkert/expand-range "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.")
|
||||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
|
||||
* [to-regex-range](https://www.npmjs.com/package/to-regex-range): Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than… [more](https://github.com/jonschlinkert/to-regex-range) | [homepage](https://github.com/jonschlinkert/to-regex-range "Pass two numbers, get a regex-compatible source string for matching ranges. Validated against more than 2.87 million test assertions.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
</details>
|
||||
### Contributors
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 103 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [paulmillr](https://github.com/paulmillr) |
|
||||
| 1 | [edorivai](https://github.com/edorivai) |
|
||||
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||
|
||||
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:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Building docs</strong></summary>
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
@@ -200,38 +225,26 @@ To generate the readme, run the following command:
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
</details>
|
||||
### Running tests
|
||||
|
||||
### Contributors
|
||||
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:
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 116 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 4 | [paulmillr](https://github.com/paulmillr) |
|
||||
| 2 | [realityking](https://github.com/realityking) |
|
||||
| 2 | [bluelovers](https://github.com/bluelovers) |
|
||||
| 1 | [edorivai](https://github.com/edorivai) |
|
||||
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||
|
||||
Please consider supporting me on Patreon, or [start your own Patreon page](https://patreon.com/invite/bxpbvm)!
|
||||
|
||||
<a href="https://www.patreon.com/jonschlinkert">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" height="50">
|
||||
</a>
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 08, 2019._
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 23, 2017._
|
||||
403
node_modules/fill-range/index.js
generated
vendored
403
node_modules/fill-range/index.js
generated
vendored
@@ -1,249 +1,208 @@
|
||||
/*!
|
||||
* fill-range <https://github.com/jonschlinkert/fill-range>
|
||||
*
|
||||
* Copyright (c) 2014-present, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
* Copyright (c) 2014-2015, 2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const toRegexRange = require('to-regex-range');
|
||||
var util = require('util');
|
||||
var isNumber = require('is-number');
|
||||
var extend = require('extend-shallow');
|
||||
var repeat = require('repeat-string');
|
||||
var toRegex = require('to-regex-range');
|
||||
|
||||
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
||||
/**
|
||||
* Return a range of numbers or letters.
|
||||
*
|
||||
* @param {String} `start` Start of the range
|
||||
* @param {String} `stop` End of the range
|
||||
* @param {String} `step` Increment or decrement to use.
|
||||
* @param {Function} `fn` Custom function to modify each element in the range.
|
||||
* @return {Array}
|
||||
*/
|
||||
|
||||
const transform = toNumber => {
|
||||
return value => toNumber === true ? Number(value) : String(value);
|
||||
};
|
||||
|
||||
const isValidValue = value => {
|
||||
return typeof value === 'number' || (typeof value === 'string' && value !== '');
|
||||
};
|
||||
|
||||
const isNumber = num => Number.isInteger(+num);
|
||||
|
||||
const zeros = input => {
|
||||
let value = `${input}`;
|
||||
let index = -1;
|
||||
if (value[0] === '-') value = value.slice(1);
|
||||
if (value === '0') return false;
|
||||
while (value[++index] === '0');
|
||||
return index > 0;
|
||||
};
|
||||
|
||||
const stringify = (start, end, options) => {
|
||||
if (typeof start === 'string' || typeof end === 'string') {
|
||||
return true;
|
||||
}
|
||||
return options.stringify === true;
|
||||
};
|
||||
|
||||
const pad = (input, maxLength, toNumber) => {
|
||||
if (maxLength > 0) {
|
||||
let dash = input[0] === '-' ? '-' : '';
|
||||
if (dash) input = input.slice(1);
|
||||
input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
|
||||
}
|
||||
if (toNumber === false) {
|
||||
return String(input);
|
||||
}
|
||||
return input;
|
||||
};
|
||||
|
||||
const toMaxLen = (input, maxLength) => {
|
||||
let negative = input[0] === '-' ? '-' : '';
|
||||
if (negative) {
|
||||
input = input.slice(1);
|
||||
maxLength--;
|
||||
}
|
||||
while (input.length < maxLength) input = '0' + input;
|
||||
return negative ? ('-' + input) : input;
|
||||
};
|
||||
|
||||
const toSequence = (parts, options) => {
|
||||
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
||||
|
||||
let prefix = options.capture ? '' : '?:';
|
||||
let positives = '';
|
||||
let negatives = '';
|
||||
let result;
|
||||
|
||||
if (parts.positives.length) {
|
||||
positives = parts.positives.join('|');
|
||||
}
|
||||
|
||||
if (parts.negatives.length) {
|
||||
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
||||
}
|
||||
|
||||
if (positives && negatives) {
|
||||
result = `${positives}|${negatives}`;
|
||||
} else {
|
||||
result = positives || negatives;
|
||||
}
|
||||
|
||||
if (options.wrap) {
|
||||
return `(${prefix}${result})`;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const toRange = (a, b, isNumbers, options) => {
|
||||
if (isNumbers) {
|
||||
return toRegexRange(a, b, { wrap: false, ...options });
|
||||
}
|
||||
|
||||
let start = String.fromCharCode(a);
|
||||
if (a === b) return start;
|
||||
|
||||
let stop = String.fromCharCode(b);
|
||||
return `[${start}-${stop}]`;
|
||||
};
|
||||
|
||||
const toRegex = (start, end, options) => {
|
||||
if (Array.isArray(start)) {
|
||||
let wrap = options.wrap === true;
|
||||
let prefix = options.capture ? '' : '?:';
|
||||
return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
|
||||
}
|
||||
return toRegexRange(start, end, options);
|
||||
};
|
||||
|
||||
const rangeError = (...args) => {
|
||||
return new RangeError('Invalid range arguments: ' + util.inspect(...args));
|
||||
};
|
||||
|
||||
const invalidRange = (start, end, options) => {
|
||||
if (options.strictRanges === true) throw rangeError([start, end]);
|
||||
return [];
|
||||
};
|
||||
|
||||
const invalidStep = (step, options) => {
|
||||
if (options.strictRanges === true) {
|
||||
throw new TypeError(`Expected step "${step}" to be a number`);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const fillNumbers = (start, end, step = 1, options = {}) => {
|
||||
let a = Number(start);
|
||||
let b = Number(end);
|
||||
|
||||
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
||||
if (options.strictRanges === true) throw rangeError([start, end]);
|
||||
function fillRange(start, stop, step, options) {
|
||||
if (typeof start === 'undefined') {
|
||||
return [];
|
||||
}
|
||||
|
||||
// fix negative zero
|
||||
if (a === 0) a = 0;
|
||||
if (b === 0) b = 0;
|
||||
|
||||
let descending = a > b;
|
||||
let startString = String(start);
|
||||
let endString = String(end);
|
||||
let stepString = String(step);
|
||||
step = Math.max(Math.abs(step), 1);
|
||||
|
||||
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
||||
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
||||
let toNumber = padded === false && stringify(start, end, options) === false;
|
||||
let format = options.transform || transform(toNumber);
|
||||
|
||||
if (options.toRegex && step === 1) {
|
||||
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
||||
}
|
||||
|
||||
let parts = { negatives: [], positives: [] };
|
||||
let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
|
||||
let range = [];
|
||||
let index = 0;
|
||||
|
||||
while (descending ? a >= b : a <= b) {
|
||||
if (options.toRegex === true && step > 1) {
|
||||
push(a);
|
||||
} else {
|
||||
range.push(pad(format(a, index), maxLen, toNumber));
|
||||
if (typeof stop === 'undefined' || start === stop) {
|
||||
// special case, for handling negative zero
|
||||
var isString = typeof start === 'string';
|
||||
if (isNumber(start) && !toNumber(start)) {
|
||||
return [isString ? '0' : 0];
|
||||
}
|
||||
a = descending ? a - step : a + step;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return step > 1
|
||||
? toSequence(parts, options)
|
||||
: toRegex(range, null, { wrap: false, ...options });
|
||||
}
|
||||
|
||||
return range;
|
||||
};
|
||||
|
||||
const fillLetters = (start, end, step = 1, options = {}) => {
|
||||
if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
|
||||
return invalidRange(start, end, options);
|
||||
}
|
||||
|
||||
|
||||
let format = options.transform || (val => String.fromCharCode(val));
|
||||
let a = `${start}`.charCodeAt(0);
|
||||
let b = `${end}`.charCodeAt(0);
|
||||
|
||||
let descending = a > b;
|
||||
let min = Math.min(a, b);
|
||||
let max = Math.max(a, b);
|
||||
|
||||
if (options.toRegex && step === 1) {
|
||||
return toRange(min, max, false, options);
|
||||
}
|
||||
|
||||
let range = [];
|
||||
let index = 0;
|
||||
|
||||
while (descending ? a >= b : a <= b) {
|
||||
range.push(format(a, index));
|
||||
a = descending ? a - step : a + step;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return toRegex(range, null, { wrap: false, options });
|
||||
}
|
||||
|
||||
return range;
|
||||
};
|
||||
|
||||
const fill = (start, end, step, options = {}) => {
|
||||
if (end == null && isValidValue(start)) {
|
||||
return [start];
|
||||
}
|
||||
|
||||
if (!isValidValue(start) || !isValidValue(end)) {
|
||||
return invalidRange(start, end, options);
|
||||
if (typeof step !== 'number' && typeof step !== 'string') {
|
||||
options = step;
|
||||
step = undefined;
|
||||
}
|
||||
|
||||
if (typeof step === 'function') {
|
||||
return fill(start, end, 1, { transform: step });
|
||||
if (typeof options === 'function') {
|
||||
options = { transform: options };
|
||||
}
|
||||
|
||||
if (isObject(step)) {
|
||||
return fill(start, end, 0, step);
|
||||
var opts = extend({step: step}, options);
|
||||
if (opts.step && !isValidNumber(opts.step)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new TypeError('expected options.step to be a number');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
let opts = { ...options };
|
||||
if (opts.capture === true) opts.wrap = true;
|
||||
step = step || opts.step || 1;
|
||||
|
||||
if (!isNumber(step)) {
|
||||
if (step != null && !isObject(step)) return invalidStep(step, opts);
|
||||
return fill(start, end, 1, step);
|
||||
opts.isNumber = isValidNumber(start) && isValidNumber(stop);
|
||||
if (!opts.isNumber && !isValid(start, stop)) {
|
||||
if (opts.strictRanges === true) {
|
||||
throw new RangeError('invalid range arguments: ' + util.inspect([start, stop]));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (isNumber(start) && isNumber(end)) {
|
||||
return fillNumbers(start, end, step, opts);
|
||||
opts.isPadded = isPadded(start) || isPadded(stop);
|
||||
opts.toString = opts.stringify
|
||||
|| typeof opts.step === 'string'
|
||||
|| typeof start === 'string'
|
||||
|| typeof stop === 'string'
|
||||
|| !opts.isNumber;
|
||||
|
||||
if (opts.isPadded) {
|
||||
opts.maxLength = Math.max(String(start).length, String(stop).length);
|
||||
}
|
||||
|
||||
return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
|
||||
};
|
||||
// support legacy minimatch/fill-range options
|
||||
if (typeof opts.optimize === 'boolean') opts.toRegex = opts.optimize;
|
||||
if (typeof opts.makeRe === 'boolean') opts.toRegex = opts.makeRe;
|
||||
return expand(start, stop, opts);
|
||||
}
|
||||
|
||||
module.exports = fill;
|
||||
function expand(start, stop, options) {
|
||||
var a = options.isNumber ? toNumber(start) : start.charCodeAt(0);
|
||||
var b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0);
|
||||
|
||||
var step = Math.abs(toNumber(options.step)) || 1;
|
||||
if (options.toRegex && step === 1) {
|
||||
return toRange(a, b, start, stop, options);
|
||||
}
|
||||
|
||||
var zero = {greater: [], lesser: []};
|
||||
var asc = a < b;
|
||||
var arr = new Array(Math.round((asc ? b - a : a - b) / step));
|
||||
var idx = 0;
|
||||
|
||||
while (asc ? a <= b : a >= b) {
|
||||
var val = options.isNumber ? a : String.fromCharCode(a);
|
||||
if (options.toRegex && (val >= 0 || !options.isNumber)) {
|
||||
zero.greater.push(val);
|
||||
} else {
|
||||
zero.lesser.push(Math.abs(val));
|
||||
}
|
||||
|
||||
if (options.isPadded) {
|
||||
val = zeros(val, options);
|
||||
}
|
||||
|
||||
if (options.toString) {
|
||||
val = String(val);
|
||||
}
|
||||
|
||||
if (typeof options.transform === 'function') {
|
||||
arr[idx++] = options.transform(val, a, b, step, idx, arr, options);
|
||||
} else {
|
||||
arr[idx++] = val;
|
||||
}
|
||||
|
||||
if (asc) {
|
||||
a += step;
|
||||
} else {
|
||||
a -= step;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.toRegex === true) {
|
||||
return toSequence(arr, zero, options);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function toRange(a, b, start, stop, options) {
|
||||
if (options.isPadded) {
|
||||
return toRegex(start, stop, options);
|
||||
}
|
||||
|
||||
if (options.isNumber) {
|
||||
return toRegex(Math.min(a, b), Math.max(a, b), options);
|
||||
}
|
||||
|
||||
var start = String.fromCharCode(Math.min(a, b));
|
||||
var stop = String.fromCharCode(Math.max(a, b));
|
||||
return '[' + start + '-' + stop + ']';
|
||||
}
|
||||
|
||||
function toSequence(arr, zeros, options) {
|
||||
var greater = '', lesser = '';
|
||||
if (zeros.greater.length) {
|
||||
greater = zeros.greater.join('|');
|
||||
}
|
||||
if (zeros.lesser.length) {
|
||||
lesser = '-(' + zeros.lesser.join('|') + ')';
|
||||
}
|
||||
var res = greater && lesser
|
||||
? greater + '|' + lesser
|
||||
: greater || lesser;
|
||||
|
||||
if (options.capture) {
|
||||
return '(' + res + ')';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function zeros(val, options) {
|
||||
if (options.isPadded) {
|
||||
var str = String(val);
|
||||
var len = str.length;
|
||||
var dash = '';
|
||||
if (str.charAt(0) === '-') {
|
||||
dash = '-';
|
||||
str = str.slice(1);
|
||||
}
|
||||
var diff = options.maxLength - len;
|
||||
var pad = repeat('0', diff);
|
||||
val = (dash + pad + str);
|
||||
}
|
||||
if (options.stringify) {
|
||||
return String(val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function toNumber(val) {
|
||||
return Number(val) || 0;
|
||||
}
|
||||
|
||||
function isPadded(str) {
|
||||
return /^-?0\d/.test(str);
|
||||
}
|
||||
|
||||
function isValid(min, max) {
|
||||
return (isValidNumber(min) || isValidLetter(min))
|
||||
&& (isValidNumber(max) || isValidLetter(max));
|
||||
}
|
||||
|
||||
function isValidLetter(ch) {
|
||||
return typeof ch === 'string' && ch.length === 1 && /^\w+$/.test(ch);
|
||||
}
|
||||
|
||||
function isValidNumber(n) {
|
||||
return isNumber(n) && !/\./.test(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `fillRange`
|
||||
* @type {Function}
|
||||
*/
|
||||
|
||||
module.exports = fillRange;
|
||||
|
||||
35
node_modules/fill-range/package.json
generated
vendored
35
node_modules/fill-range/package.json
generated
vendored
@@ -1,15 +1,14 @@
|
||||
{
|
||||
"name": "fill-range",
|
||||
"description": "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`",
|
||||
"version": "7.0.1",
|
||||
"version": "4.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/fill-range",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Edo Rivai (edo.rivai.nl)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Paul Miller (paulmillr.com)",
|
||||
"Rouven Weßling (www.rouvenwessling.de)",
|
||||
"(https://github.com/wtgtybhertgeghgtwtg)"
|
||||
"<wtgtybhertgeghgtwtg@gmail.com> (https://github.com/wtgtybhertgeghgtwtg)",
|
||||
"Edo Rivai <edo.rivai@gmail.com> (edo.rivai.nl)",
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
|
||||
"Paul Miller <paul+gh@paulmillr.com> (paulmillr.com)"
|
||||
],
|
||||
"repository": "jonschlinkert/fill-range",
|
||||
"bugs": {
|
||||
@@ -21,17 +20,23 @@
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
"extend-shallow": "^2.0.1",
|
||||
"is-number": "^3.0.0",
|
||||
"repeat-string": "^1.6.1",
|
||||
"to-regex-range": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^2.0.0",
|
||||
"mocha": "^6.1.1"
|
||||
"ansi-cyan": "^0.1.1",
|
||||
"benchmarked": "^1.0.0",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"alpha",
|
||||
@@ -54,7 +59,15 @@
|
||||
"sh"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"related": {
|
||||
"list": [
|
||||
"braces",
|
||||
"expand-range",
|
||||
"micromatch",
|
||||
"to-regex-range"
|
||||
]
|
||||
},
|
||||
"toc": true,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
|
||||
Reference in New Issue
Block a user