diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/fill-range | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/fill-range')
-rw-r--r--[-rwxr-xr-x] | node_modules/fill-range/LICENSE | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | node_modules/fill-range/README.md | 340 | ||||
-rw-r--r-- | node_modules/fill-range/index.js | 456 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/is-number/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/is-number/README.md | 103 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/is-number/index.js | 19 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/is-number/package.json | 59 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/isobject/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/isobject/README.md | 112 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/isobject/index.js | 14 | ||||
-rw-r--r-- | node_modules/fill-range/node_modules/isobject/package.json | 67 | ||||
-rw-r--r-- | node_modules/fill-range/package.json | 47 |
12 files changed, 313 insertions, 948 deletions
diff --git a/node_modules/fill-range/LICENSE b/node_modules/fill-range/LICENSE index fa30c4cb3..d734237bd 100755..100644 --- a/node_modules/fill-range/LICENSE +++ b/node_modules/fill-range/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2015, 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 diff --git a/node_modules/fill-range/README.md b/node_modules/fill-range/README.md index c69694a38..bc1f8a044 100755..100644 --- a/node_modules/fill-range/README.md +++ b/node_modules/fill-range/README.md @@ -1,290 +1,250 @@ -# fill-range [](http://badge.fury.io/js/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 multiplier to use. +> 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` -## Install with [npm](npmjs.org) - -```bash -npm i fill-range --save -``` - -<!-- toc --> +## Table of Contents +- [Install](#install) - [Usage](#usage) - * [Invalid ranges](#invalid-ranges) - * [Custom function](#custom-function) - * [Special characters](#special-characters) - + [plus](#plus) - + [pipe and tilde](#pipe-and-tilde) - + [angle bracket](#angle-bracket) - + [question mark](#question-mark) -- [Other useful libs](#other-useful-libs) -- [Running tests](#running-tests) -- [Contributing](#contributing) -- [Author](#author) -- [License](#license) - -_(Table of contents generated by [verb])_ - -<!-- tocstop --> +- [Examples](#examples) +- [Options](#options) + * [options.step](#optionsstep) + * [options.strictRanges](#optionsstrictranges) + * [options.stringify](#optionsstringify) + * [options.toRegex](#optionstoregex) + * [options.transform](#optionstransform) +- [About](#about) -## Usage +_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_ -```js -var range = require('fill-range'); +## Install + +Install with [npm](https://www.npmjs.com/): -range('a', 'e'); -//=> ['a', 'b', 'c', 'd', 'e'] +```sh +$ npm install --save fill-range ``` -**Params** +Install with [yarn](https://yarnpkg.com): -```js -range(start, stop, step, options, fn); +```sh +$ yarn add fill-range ``` - - `start`: **{String|Number}** the number or letter to start with - - `end`: **{String|Number}** the number or letter to end with - - `step`: **{String|Number}** optionally pass the step to use. works for letters or numbers. - - `options`: **{Object}**: - + `makeRe`: return a regex-compatible string (still returned as an array for consistency) - + `step`: pass the step on the options as an alternative to passing it as an argument - + `silent`: `true` by default, set to false to throw errors for invalid ranges. - - `fn`: **{Function}** optionally [pass a function](#custom-function) to modify each character - +## Usage -**Examples** +Expands numbers and letters, optionally using a `step` as the last argument. _(Numbers may be defined as JavaScript numbers or strings)_. ```js -range(1, 3) -//=> ['1', '2', '3'] - -range('1', '3') -//=> ['1', '2', '3'] +var fill = require('fill-range'); +fill(from, to[, step, options]); -range('0', '-5') -//=> [ '0', '-1', '-2', '-3', '-4', '-5' ] +// 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 +``` -range(-9, 9, 3) -//=> [ '-9', '-6', '-3', '0', '3', '6', '9' ]) +**Params** -range('-1', '-10', '-2') -//=> [ '-1', '-3', '-5', '-7', '-9' ] +* `from`: **{String|Number}** the number or letter to start with +* `to`: **{String|Number}** the number or letter to end with +* `step`: **{String|Number|Object|Function}** Optionally pass a [step](#optionsstep) to use. +* `options`: **{Object|Function}**: See all available [options](#options) -range('1', '10', '2') -//=> [ '1', '3', '5', '7', '9' ] +## Examples -range('a', 'e') -//=> ['a', 'b', 'c', 'd', 'e'] +By default, an array of values is returned. -range('a', 'e', 2) -//=> ['a', 'c', 'e'] +**Alphabetical ranges** -range('A', 'E', 2) -//=> ['A', 'C', 'E'] +```js +console.log(fill('a', 'e')); //=> ['a', 'b', 'c', 'd', 'e'] +console.log(fill('A', 'E')); //=> [ 'A', 'B', 'C', 'D', 'E' ] ``` -### Invalid ranges +**Numerical ranges** -When an invalid range is passed, `null` is returned. +Numbers can be defined as actual numbers or strings. ```js -range('1.1', '2'); -//=> null - -range('a', '2'); -//=> null - -range(1, 10, 'foo'); -//=> null +console.log(fill(1, 5)); //=> [ 1, 2, 3, 4, 5 ] +console.log(fill('1', '5')); //=> [ 1, 2, 3, 4, 5 ] ``` -If you want errors to be throw, pass `silent: false` on the options: +**Negative ranges** - -### Custom function - -Optionally pass a custom function as the third or fourth argument: +Numbers can be defined as actual numbers or strings. ```js -range('a', 'e', function (val, isNumber, pad, i) { - if (!isNumber) { - return String.fromCharCode(val) + i; - } - return val; -}); -//=> ['a0', 'b1', 'c2', 'd3', 'e4'] +console.log(fill('-5', '-1')); //=> [ '-5', '-4', '-3', '-2', '-1' ] +console.log(fill('-5', '5')); //=> [ '-5', '-4', '-3', '-2', '-1', '0', '1', '2', '3', '4', '5' ] ``` -### Special characters - -A special character may be passed as the third arg instead of a step increment. These characters can be pretty useful for brace expansion, creating file paths, test fixtures and similar use case. +**Steps (increments)** ```js -range('a', 'z', SPECIAL_CHARACTER_HERE); +// numerical ranges with increments +console.log(fill('0', '25', 4)); //=> [ '0', '4', '8', '12', '16', '20', '24' ] +console.log(fill('0', '25', 5)); //=> [ '0', '5', '10', '15', '20', '25' ] +console.log(fill('0', '25', 6)); //=> [ '0', '6', '12', '18', '24' ] + +// alphabetical ranges with increments +console.log(fill('a', 'z', 4)); //=> [ 'a', 'e', 'i', 'm', 'q', 'u', 'y' ] +console.log(fill('a', 'z', 5)); //=> [ 'a', 'f', 'k', 'p', 'u', 'z' ] +console.log(fill('a', 'z', 6)); //=> [ 'a', 'g', 'm', 's', 'y' ] ``` -**Supported characters** +## Options - - `+`: repeat the given string `n` times - - `|`: create a regex-ready string, instead of an array - - `>`: join values to single array element - - `?`: randomize the given pattern using [randomatic] +### options.step -#### plus +**Type**: `number` (formatted as a string or number) -Character: _(`+`)_ +**Default**: `undefined` -Repeat the first argument the number of times passed on the second argument. +**Description**: The increment to use for the range. Can be used with letters or numbers. -**Examples:** +**Example(s)** ```js -range('a', 3, '+'); -//=> ['a', 'a', 'a'] +// numbers +console.log(fill('1', '10', 2)); //=> [ '1', '3', '5', '7', '9' ] +console.log(fill('1', '10', 3)); //=> [ '1', '4', '7', '10' ] +console.log(fill('1', '10', 4)); //=> [ '1', '5', '9' ] -range('abc', 2, '+'); -//=> ['abc', 'abc'] +// letters +console.log(fill('a', 'z', 5)); //=> [ 'a', 'f', 'k', 'p', 'u', 'z' ] +console.log(fill('a', 'z', 7)); //=> [ 'a', 'h', 'o', 'v' ] +console.log(fill('a', 'z', 9)); //=> [ 'a', 'j', 's' ] ``` -#### pipe and tilde +### options.strictRanges -Characters: _(`|` and `~`)_ +**Type**: `boolean` -Creates a regex-capable string (either a logical `or` or a character class) from the expanded arguments. +**Default**: `false` -**Examples:** +**Description**: By default, `null` is returned when an invalid range is passed. Enable this option to throw a `RangeError` on invalid ranges. -```js -range('a', 'c', '|'); -//=> ['(a|b|c)' +**Example(s)** -range('a', 'c', '~'); -//=> ['[a-c]' +The following are all invalid: -range('a', 'z', '|5'); -//=> ['(a|f|k|p|u|z)' +```js +fill('1.1', '2'); // decimals not supported in ranges +fill('a', '2'); // incompatible range values +fill(1, 10, 'foo'); // invalid "step" argument ``` -**Automatic separator correction** - -To avoid this error: +### options.stringify -> `Range out of order in character class` +**Type**: `boolean` -Fill-range detects invalid sequences and uses the correct syntax. For example: +**Default**: `undefined` -**invalid** (regex) +**Description**: Cast all returned values to strings. By default, integers are returned as numbers. -If you pass these: +**Example(s)** ```js -range('a', 'z', '~5'); -// which would result in this -//=> ['[a-f-k-p-u-z]'] - -range('10', '20', '~'); -// which would result in this -//=> ['[10-20]'] +console.log(fill(1, 5)); //=> [ 1, 2, 3, 4, 5 ] +console.log(fill(1, 5, {stringify: true})); //=> [ '1', '2', '3', '4', '5' ] ``` -**valid** (regex) +### options.toRegex -fill-range corrects them to this: +**Type**: `boolean` -```js -range('a', 'z', '~5'); -//=> ['(a|f|k|p|u|z)' +**Default**: `undefined` + +**Description**: Create a regex-compatible source string, instead of expanding values to an array. -range('10', '20', '~'); -//=> ['(10-20)' +**Example(s)** + +```js +// alphabetical range +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' +// numerical range +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})); +//=> '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' ``` -#### angle bracket +### options.transform -Character: _(`>`)_ +**Type**: `function` -Joins all values in the returned array to a single value. +**Default**: `undefined` -**Examples:** +**Description**: Customize each value in the returned array (or [string](#optionstoRegex)). _(you can also pass this function as the last argument to `fill()`)_. -```js -range('a', 'e', '>'); -//=> ['abcde'] +**Example(s)** -range('5', '8', '>'); -//=> ['5678'] +```js +// 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; +}); -range('2', '20', '2>'); -//=> ['2468101214161820'] +console.log(arr); +//=> ['0001', '0002', '0003', '0004', '0005'] ``` +## About -#### question mark +### Related projects -Character: _(`?`)_ +* [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.") -Uses [randomatic] to generate randomized alpha, numeric, or alpha-numeric patterns based on the provided arguments. +### Contributing -**Examples:** +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). -_(actual results would obviously be randomized)_ +### Contributors -Generate a 5-character, uppercase, alphabetical string: +| **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) | -```js -range('A', 5, '?'); -//=> ['NSHAK'] -``` - -Generate a 5-digit random number: +### Building docs -```js -range('0', 5, '?'); -//=> ['36583'] -``` +_(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.)_ -Generate a 10-character alpha-numeric string: +To generate the readme, run the following command: -```js -range('A0', 10, '?'); -//=> ['5YJD60VQNN'] +```sh +$ npm install -g verbose/verb#dev verb-generate-readme && verb ``` -See the [randomatic] repo for all available options and or to create issues or feature requests related to randomization. - -## Other useful libs - * [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`. - * [expand-range](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. - * [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces specification. - * [is-glob](https://github.com/jonschlinkert/is-glob): Returns `true` if the given string looks like a glob pattern. +### Running tests -## Running tests -Install dev dependencies: +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: -```bash -npm i -d && npm test +```sh +$ npm install && npm test ``` -## Contributing -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/fill-range/issues) - -## Author +### Author **Jon Schlinkert** -+ [github/jonschlinkert](https://github.com/jonschlinkert) -+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) +* [github/jonschlinkert](https://github.com/jonschlinkert) +* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) -## License -Copyright (c) 2014-2015 Jon Schlinkert -Released under the MIT license +### License -*** +Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). -_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 07, 2015._ +*** -[randomatic]: https://github.com/jonschlinkert/randomatic -[expand-range]: https://github.com/jonschlinkert/expand-range -[micromatch]: https://github.com/jonschlinkert/micromatch -[braces]: https://github.com/jonschlinkert/braces
\ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 23, 2017._
\ No newline at end of file diff --git a/node_modules/fill-range/index.js b/node_modules/fill-range/index.js index 5657051be..294a2edde 100644 --- a/node_modules/fill-range/index.js +++ b/node_modules/fill-range/index.js @@ -1,408 +1,208 @@ /*! * fill-range <https://github.com/jonschlinkert/fill-range> * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. + * Copyright (c) 2014-2015, 2017, Jon Schlinkert. + * Released under the MIT License. */ 'use strict'; -var isObject = require('isobject'); +var util = require('util'); var isNumber = require('is-number'); -var randomize = require('randomatic'); -var repeatStr = require('repeat-string'); -var repeat = require('repeat-element'); - -/** - * Expose `fillRange` - */ - -module.exports = fillRange; +var extend = require('extend-shallow'); +var repeat = require('repeat-string'); +var toRegex = require('to-regex-range'); /** * Return a range of numbers or letters. * - * @param {String} `a` Start of the range - * @param {String} `b` End of the range + * @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} */ -function fillRange(a, b, step, options, fn) { - if (a == null || b == null) { - throw new Error('fill-range expects the first and second args to be strings.'); - } - - if (typeof step === 'function') { - fn = step; options = {}; step = null; - } - - if (typeof options === 'function') { - fn = options; options = {}; - } - - if (isObject(step)) { - options = step; step = ''; +function fillRange(start, stop, step, options) { + if (typeof start === 'undefined') { + return []; } - var expand, regex = false, sep = ''; - var opts = options || {}; - - if (typeof opts.silent === 'undefined') { - opts.silent = true; + 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]; + } + return [start]; } - step = step || opts.step; - - // store a ref to unmodified arg - var origA = a, origB = b; - - b = (b.toString() === '-0') ? 0 : b; - - if (opts.optimize || opts.makeRe) { - step = step ? (step += '~') : step; - expand = true; - regex = true; - sep = '~'; + if (typeof step !== 'number' && typeof step !== 'string') { + options = step; + step = undefined; } - // handle special step characters - if (typeof step === 'string') { - var match = stepRe().exec(step); - - if (match) { - var i = match.index; - var m = match[0]; - - // repeat string - if (m === '+') { - return repeat(a, b); - - // randomize a, `b` times - } else if (m === '?') { - return [randomize(a, b)]; - - // expand right, no regex reduction - } else if (m === '>') { - step = step.substr(0, i) + step.substr(i + 1); - expand = true; - - // expand to an array, or if valid create a reduced - // string for a regex logic `or` - } else if (m === '|') { - step = step.substr(0, i) + step.substr(i + 1); - expand = true; - regex = true; - sep = m; - - // expand to an array, or if valid create a reduced - // string for a regex range - } else if (m === '~') { - step = step.substr(0, i) + step.substr(i + 1); - expand = true; - regex = true; - sep = m; - } - } else if (!isNumber(step)) { - if (!opts.silent) { - throw new TypeError('fill-range: invalid step.'); - } - return null; - } + if (typeof options === 'function') { + options = { transform: options }; } - if (/[.&*()[\]^%$#@!]/.test(a) || /[.&*()[\]^%$#@!]/.test(b)) { - if (!opts.silent) { - throw new RangeError('fill-range: invalid range arguments.'); + 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 null; + return []; } - // has neither a letter nor number, or has both letters and numbers - // this needs to be after the step logic - if (!noAlphaNum(a) || !noAlphaNum(b) || hasBoth(a) || hasBoth(b)) { - if (!opts.silent) { - throw new RangeError('fill-range: invalid range arguments.'); + 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 null; + return []; } - // validate arguments - var isNumA = isNumber(zeros(a)); - var isNumB = isNumber(zeros(b)); + opts.isPadded = isPadded(start) || isPadded(stop); + opts.toString = opts.stringify + || typeof opts.step === 'string' + || typeof start === 'string' + || typeof stop === 'string' + || !opts.isNumber; - if ((!isNumA && isNumB) || (isNumA && !isNumB)) { - if (!opts.silent) { - throw new TypeError('fill-range: first range argument is incompatible with second.'); - } - return null; + if (opts.isPadded) { + opts.maxLength = Math.max(String(start).length, String(stop).length); } - // by this point both are the same, so we - // can use A to check going forward. - var isNum = isNumA; - var num = formatStep(step); - - // is the range alphabetical? or numeric? - if (isNum) { - // if numeric, coerce to an integer - a = +a; b = +b; - } else { - // otherwise, get the charCode to expand alpha ranges - a = a.charCodeAt(0); - b = b.charCodeAt(0); - } + // 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); +} - // is the pattern descending? - var isDescending = a > b; +function expand(start, stop, options) { + var a = options.isNumber ? toNumber(start) : start.charCodeAt(0); + var b = options.isNumber ? toNumber(stop) : stop.charCodeAt(0); - // don't create a character class if the args are < 0 - if (a < 0 || b < 0) { - expand = false; - regex = false; + var step = Math.abs(toNumber(options.step)) || 1; + if (options.toRegex && step === 1) { + return toRange(a, b, start, stop, options); } - // detect padding - var padding = isPadded(origA, origB); - var res, pad, arr = []; - var ii = 0; - - // character classes, ranges and logical `or` - if (regex) { - if (shouldExpand(a, b, num, isNum, padding, opts)) { - // make sure the correct separator is used - if (sep === '|' || sep === '~') { - sep = detectSeparator(a, b, num, isNum, isDescending); - } - return wrap([origA, origB], sep, opts); - } - } + var zero = {greater: [], lesser: []}; + var asc = a < b; + var arr = new Array(Math.round((asc ? b - a : a - b) / step)); + var idx = 0; - while (isDescending ? (a >= b) : (a <= b)) { - if (padding && isNum) { - pad = padding(a); + 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)); } - // custom function - if (typeof fn === 'function') { - res = fn(a, isNum, pad, ii++); + if (options.isPadded) { + val = zeros(val, options); + } - // letters - } else if (!isNum) { - if (regex && isInvalidChar(a)) { - res = null; - } else { - res = String.fromCharCode(a); - } + if (options.toString) { + val = String(val); + } - // numbers + if (typeof options.transform === 'function') { + arr[idx++] = options.transform(val, a, b, step, idx, arr, options); } else { - res = formatPadding(a, pad); + arr[idx++] = val; } - // add result to the array, filtering any nulled values - if (res !== null) arr.push(res); - - // increment or decrement - if (isDescending) { - a -= num; + if (asc) { + a += step; } else { - a += num; + a -= step; } } - // now that the array is expanded, we need to handle regex - // character classes, ranges or logical `or` that wasn't - // already handled before the loop - if ((regex || expand) && !opts.noexpand) { - // make sure the correct separator is used - if (sep === '|' || sep === '~') { - sep = detectSeparator(a, b, num, isNum, isDescending); - } - if (arr.length === 1 || a < 0 || b < 0) { return arr; } - return wrap(arr, sep, opts); + if (options.toRegex === true) { + return toSequence(arr, zero, options); } - return arr; } -/** - * Wrap the string with the correct regex - * syntax. - */ - -function wrap(arr, sep, opts) { - if (sep === '~') { sep = '-'; } - var str = arr.join(sep); - var pre = opts && opts.regexPrefix; - - // regex logical `or` - if (sep === '|') { - str = pre ? pre + str : str; - str = '(' + str + ')'; +function toRange(a, b, start, stop, options) { + if (options.isPadded) { + return toRegex(start, stop, options); } - // regex character class - if (sep === '-') { - str = (pre && pre === '^') - ? pre + str - : str; - str = '[' + str + ']'; + if (options.isNumber) { + return toRegex(Math.min(a, b), Math.max(a, b), options); } - return [str]; -} -/** - * Check for invalid characters - */ - -function isCharClass(a, b, step, isNum, isDescending) { - if (isDescending) { return false; } - if (isNum) { return a <= 9 && b <= 9; } - if (a < b) { return step === 1; } - return false; -} - -/** - * Detect the correct separator to use - */ - -function shouldExpand(a, b, num, isNum, padding, opts) { - if (isNum && (a > 9 || b > 9)) { return false; } - return !padding && num === 1 && a < b; + var start = String.fromCharCode(Math.min(a, b)); + var stop = String.fromCharCode(Math.max(a, b)); + return '[' + start + '-' + stop + ']'; } -/** - * Detect the correct separator to use - */ - -function detectSeparator(a, b, step, isNum, isDescending) { - var isChar = isCharClass(a, b, step, isNum, isDescending); - if (!isChar) { - return '|'; +function toSequence(arr, zeros, options) { + var greater = '', lesser = ''; + if (zeros.greater.length) { + greater = zeros.greater.join('|'); } - return '~'; -} - -/** - * Correctly format the step based on type - */ + if (zeros.lesser.length) { + lesser = '-(' + zeros.lesser.join('|') + ')'; + } + var res = greater && lesser + ? greater + '|' + lesser + : greater || lesser; -function formatStep(step) { - return Math.abs(step >> 0) || 1; + if (options.capture) { + return '(' + res + ')'; + } + return res; } -/** - * Format padding, taking leading `-` into account - */ - -function formatPadding(ch, pad) { - var res = pad ? pad + ch : ch; - if (pad && ch.toString().charAt(0) === '-') { - res = '-' + pad + ch.toString().substr(1); +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); } - return res.toString(); + if (options.stringify) { + return String(val); + } + return val; } -/** - * Check for invalid characters - */ - -function isInvalidChar(str) { - var ch = toStr(str); - return ch === '\\' - || ch === '[' - || ch === ']' - || ch === '^' - || ch === '(' - || ch === ')' - || ch === '`'; +function toNumber(val) { + return Number(val) || 0; } -/** - * Convert to a string from a charCode - */ - -function toStr(ch) { - return String.fromCharCode(ch); +function isPadded(str) { + return /^-?0\d/.test(str); } - -/** - * Step regex - */ - -function stepRe() { - return /\?|>|\||\+|\~/g; +function isValid(min, max) { + return (isValidNumber(min) || isValidLetter(min)) + && (isValidNumber(max) || isValidLetter(max)); } -/** - * Return true if `val` has either a letter - * or a number - */ - -function noAlphaNum(val) { - return /[a-z0-9]/i.test(val); +function isValidLetter(ch) { + return typeof ch === 'string' && ch.length === 1 && /^\w+$/.test(ch); } -/** - * Return true if `val` has both a letter and - * a number (invalid) - */ - -function hasBoth(val) { - return /[a-z][0-9]|[0-9][a-z]/i.test(val); +function isValidNumber(n) { + return isNumber(n) && !/\./.test(n); } /** - * Normalize zeros for checks - */ - -function zeros(val) { - if (/^-*0+$/.test(val.toString())) { - return '0'; - } - return val; -} - -/** - * Return true if `val` has leading zeros, - * or a similar valid pattern. - */ - -function hasZeros(val) { - return /[^.]\.|^-*0+[0-9]/.test(val); -} - -/** - * If the string is padded, returns a curried function with - * the a cached padding string, or `false` if no padding. - * - * @param {*} `origA` String or number. - * @return {String|Boolean} - */ - -function isPadded(origA, origB) { - if (hasZeros(origA) || hasZeros(origB)) { - var alen = length(origA); - var blen = length(origB); - - var len = alen >= blen - ? alen - : blen; - - return function (a) { - return repeatStr('0', len - length(a)); - }; - } - return false; -} - -/** - * Get the string length of `val` + * Expose `fillRange` + * @type {Function} */ -function length(val) { - return val.toString().length; -} +module.exports = fillRange; diff --git a/node_modules/fill-range/node_modules/is-number/LICENSE b/node_modules/fill-range/node_modules/is-number/LICENSE deleted file mode 100644 index fa30c4cb3..000000000 --- a/node_modules/fill-range/node_modules/is-number/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2015, 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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/fill-range/node_modules/is-number/README.md b/node_modules/fill-range/node_modules/is-number/README.md deleted file mode 100644 index 8395f9131..000000000 --- a/node_modules/fill-range/node_modules/is-number/README.md +++ /dev/null @@ -1,103 +0,0 @@ -# is-number [](http://badge.fury.io/js/is-number) [](https://travis-ci.org/jonschlinkert/is-number) - -> Returns true if the value is a number. comprehensive tests. - -To understand some of the rationale behind the decisions made in this library (and to learn about some oddities of number evaluation in JavaScript), [see this gist](https://gist.github.com/jonschlinkert/e30c70c713da325d0e81). - -## Install - -Install with [npm](https://www.npmjs.com/) - -```sh -$ npm i is-number --save -``` - -## Usage - -```js -var isNumber = require('is-number'); -``` - -### true - -See the [tests](./test.js) for more examples. - -```js -isNumber(5e3) //=> 'true' -isNumber(0xff) //=> 'true' -isNumber(-1.1) //=> 'true' -isNumber(0) //=> 'true' -isNumber(1) //=> 'true' -isNumber(1.1) //=> 'true' -isNumber(10) //=> 'true' -isNumber(10.10) //=> 'true' -isNumber(100) //=> 'true' -isNumber('-1.1') //=> 'true' -isNumber('0') //=> 'true' -isNumber('012') //=> 'true' -isNumber('0xff') //=> 'true' -isNumber('1') //=> 'true' -isNumber('1.1') //=> 'true' -isNumber('10') //=> 'true' -isNumber('10.10') //=> 'true' -isNumber('100') //=> 'true' -isNumber('5e3') //=> 'true' -isNumber(parseInt('012')) //=> 'true' -isNumber(parseFloat('012')) //=> 'true' -``` - -### False - -See the [tests](./test.js) for more examples. - -```js -isNumber('foo') //=> 'false' -isNumber([1]) //=> 'false' -isNumber([]) //=> 'false' -isNumber(function () {}) //=> 'false' -isNumber(Infinity) //=> 'false' -isNumber(NaN) //=> 'false' -isNumber(new Array('abc')) //=> 'false' -isNumber(new Array(2)) //=> 'false' -isNumber(new Buffer('abc')) //=> 'false' -isNumber(null) //=> 'false' -isNumber(undefined) //=> 'false' -isNumber({abc: 'abc'}) //=> 'false' -``` - -## Other projects - -* [even](https://www.npmjs.com/package/even): Get the even numbered items from an array. | [homepage](https://github.com/jonschlinkert/even) -* [is-even](https://www.npmjs.com/package/is-even): Return true if the given number is even. | [homepage](https://github.com/jonschlinkert/is-even) -* [is-odd](https://www.npmjs.com/package/is-odd): Returns true if the given number is odd. | [homepage](https://github.com/jonschlinkert/is-odd) -* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive) -* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of) -* [odd](https://www.npmjs.com/package/odd): Get the odd numbered items from an array. | [homepage](https://github.com/jonschlinkert/odd) - -## Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/is-number/issues/new). - -## Run tests - -Install dev dependencies: - -```sh -$ npm i -d && npm test -``` - -## Author - -**Jon Schlinkert** - -+ [github/jonschlinkert](https://github.com/jonschlinkert) -+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) - -## License - -Copyright © 2015 Jon Schlinkert -Released under the MIT license. - -*** - -_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 22, 2015._
\ No newline at end of file diff --git a/node_modules/fill-range/node_modules/is-number/index.js b/node_modules/fill-range/node_modules/is-number/index.js deleted file mode 100644 index 96ec66d5e..000000000 --- a/node_modules/fill-range/node_modules/is-number/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * is-number <https://github.com/jonschlinkert/is-number> - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - -'use strict'; - -var typeOf = require('kind-of'); - -module.exports = function isNumber(num) { - var type = typeOf(num); - if (type !== 'number' && type !== 'string') { - return false; - } - var n = +num; - return (n - n + 1) >= 0 && num !== ''; -}; diff --git a/node_modules/fill-range/node_modules/is-number/package.json b/node_modules/fill-range/node_modules/is-number/package.json deleted file mode 100644 index 8e30b1301..000000000 --- a/node_modules/fill-range/node_modules/is-number/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "is-number", - "description": "Returns true if the value is a number. comprehensive tests.", - "version": "2.1.0", - "homepage": "https://github.com/jonschlinkert/is-number", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "repository": "jonschlinkert/is-number", - "bugs": { - "url": "https://github.com/jonschlinkert/is-number/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, - "dependencies": { - "kind-of": "^3.0.2" - }, - "devDependencies": { - "benchmarked": "^0.1.3", - "chalk": "^0.5.1", - "mocha": "*" - }, - "keywords": [ - "check", - "coerce", - "coercion", - "integer", - "is", - "is number", - "is-number", - "istype", - "kind of", - "math", - "number", - "test", - "type", - "typeof", - "value" - ], - "verb": { - "related": { - "list": [ - "kind-of", - "is-primitive", - "even", - "odd", - "is-even", - "is-odd" - ] - } - } -} diff --git a/node_modules/fill-range/node_modules/isobject/LICENSE b/node_modules/fill-range/node_modules/isobject/LICENSE deleted file mode 100644 index 39245ac1c..000000000 --- a/node_modules/fill-range/node_modules/isobject/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2016, 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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/fill-range/node_modules/isobject/README.md b/node_modules/fill-range/node_modules/isobject/README.md deleted file mode 100644 index 9dd897aa0..000000000 --- a/node_modules/fill-range/node_modules/isobject/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# isobject [](https://www.npmjs.com/package/isobject) [](https://npmjs.org/package/isobject) [](https://travis-ci.org/jonschlinkert/isobject) - -Returns true if the value is an object and not an array or null. - -## Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm install isobject --save -``` - -Use [is-plain-object](https://github.com/jonschlinkert/is-plain-object) if you want only objects that are created by the `Object` constructor. - -## Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm install isobject -``` - -Install with [bower](http://bower.io/) - -```sh -$ bower install isobject -``` - -## Usage - -```js -var isObject = require('isobject'); -``` - -**True** - -All of the following return `true`: - -```js -isObject({}); -isObject(Object.create({})); -isObject(Object.create(Object.prototype)); -isObject(Object.create(null)); -isObject({}); -isObject(new Foo); -isObject(/foo/); -``` - -**False** - -All of the following return `false`: - -```js -isObject(); -isObject(function () {}); -isObject(1); -isObject([]); -isObject(undefined); -isObject(null); -``` - -## Related projects - -You might also be interested in these projects: - -[merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep) - -* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow) -* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object) -* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of) - -## Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/isobject/issues/new). - -## Building docs - -Generate readme and API documentation with [verb](https://github.com/verbose/verb): - -```sh -$ npm install verb && npm run docs -``` - -Or, if [verb](https://github.com/verbose/verb) is installed globally: - -```sh -$ verb -``` - -## Running tests - -Install dev dependencies: - -```sh -$ npm install -d && npm test -``` - -## Author - -**Jon Schlinkert** - -* [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) - -## License - -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](https://github.com/jonschlinkert/isobject/blob/master/LICENSE). - -*** - -_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 25, 2016._
\ No newline at end of file diff --git a/node_modules/fill-range/node_modules/isobject/index.js b/node_modules/fill-range/node_modules/isobject/index.js deleted file mode 100644 index aa0dce0bb..000000000 --- a/node_modules/fill-range/node_modules/isobject/index.js +++ /dev/null @@ -1,14 +0,0 @@ -/*! - * isobject <https://github.com/jonschlinkert/isobject> - * - * Copyright (c) 2014-2015, Jon Schlinkert. - * Licensed under the MIT License. - */ - -'use strict'; - -var isArray = require('isarray'); - -module.exports = function isObject(val) { - return val != null && typeof val === 'object' && isArray(val) === false; -}; diff --git a/node_modules/fill-range/node_modules/isobject/package.json b/node_modules/fill-range/node_modules/isobject/package.json deleted file mode 100644 index 954f4113f..000000000 --- a/node_modules/fill-range/node_modules/isobject/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "isobject", - "description": "Returns true if the value is an object and not an array or null.", - "version": "2.1.0", - "homepage": "https://github.com/jonschlinkert/isobject", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "repository": "jonschlinkert/isobject", - "bugs": { - "url": "https://github.com/jonschlinkert/isobject/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, - "dependencies": { - "isarray": "1.0.0" - }, - "devDependencies": { - "gulp-format-md": "^0.1.9", - "mocha": "^2.4.5" - }, - "keywords": [ - "check", - "is", - "is-object", - "isobject", - "kind", - "kind-of", - "kindof", - "native", - "object", - "type", - "typeof", - "value" - ], - "verb": { - "related": { - "list": [ - "merge-deep", - "extend-shallow", - "is-plain-object", - "kind-of" - ] - }, - "toc": false, - "layout": "default", - "tasks": [ - "readme" - ], - "plugins": [ - "gulp-format-md" - ], - "lint": { - "reflinks": true - }, - "reflinks": [ - "verb" - ] - } -} diff --git a/node_modules/fill-range/package.json b/node_modules/fill-range/package.json index a8a7bcffe..fa17dd214 100644 --- a/node_modules/fill-range/package.json +++ b/node_modules/fill-range/package.json @@ -1,9 +1,15 @@ { "name": "fill-range", - "description": "Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.", - "version": "2.2.3", + "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": "4.0.0", "homepage": "https://github.com/jonschlinkert/fill-range", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "contributors": [ + "<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": { "url": "https://github.com/jonschlinkert/fill-range/issues" @@ -20,24 +26,27 @@ "test": "mocha" }, "dependencies": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^1.1.3", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" }, "devDependencies": { - "benchmarked": "^0.1.3", - "chalk": "^0.5.1", - "should": "*" + "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", "alphabetical", + "array", "bash", "brace", "expand", "expansion", + "fill", "glob", "match", "matches", @@ -46,16 +55,28 @@ "numerical", "range", "ranges", + "regex", "sh" ], "verb": { "related": { "list": [ - "micromatch", - "expand-range", "braces", - "is-glob" + "expand-range", + "micromatch", + "to-regex-range" ] + }, + "toc": true, + "layout": "default", + "tasks": [ + "readme" + ], + "plugins": [ + "gulp-format-md" + ], + "lint": { + "reflinks": true } } } |