expand-range
Advanced tools
Comparing version 1.4.0 to 1.5.0
25
index.js
@@ -17,25 +17,20 @@ /*! | ||
// create arguments to pass to fill-range | ||
var args = str.split('..'); | ||
var len = args.length; | ||
var makeRe; | ||
if (typeof fn === 'boolean') { | ||
makeRe = fn; | ||
fn = null; | ||
} | ||
// if only one argument, it can't expand so return it | ||
if (len === 1) { return args; } | ||
if (len === 2 && makeRe) { | ||
return ['[' + args.join('-') + ']']; | ||
} | ||
// if `true`, tell fill-range to regexify the string | ||
if (typeof fn === 'boolean' && fn === true) { | ||
fn = '~'; | ||
if (len === 3 && makeRe) { | ||
args[2] = args[2] + '|'; | ||
return fill.apply(fill, args); | ||
if (len === 3) { | ||
args[len - 1] += fn; | ||
fn = null; | ||
} | ||
} | ||
if (len <= 1) { | ||
return [str]; | ||
} | ||
return fill.apply(fill, args.concat(fn)); | ||
}; |
{ | ||
"name": "expand-range", | ||
"description": "Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"homepage": "https://github.com/jonschlinkert/expand-range", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"dependencies": { | ||
"fill-range": "^1.6.0" | ||
"fill-range": "^1.7.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "devDependencies": { |
@@ -33,5 +33,11 @@ # expand-range [![NPM version](https://badge.fury.io/js/expand-range.svg)](http://badge.fury.io/js/expand-range) | ||
```js | ||
expand('1..3') | ||
//=> ['1', '2', '3'] | ||
expand('a..e') | ||
//=> ['a', 'b', 'c', 'd', 'e'] | ||
expand('a..e..2') | ||
//=> ['a', 'c', 'e'] | ||
expand('A..E..2') | ||
//=> ['A', 'C', 'E'] | ||
expand('1..3') | ||
@@ -51,11 +57,2 @@ //=> ['1', '2', '3'] | ||
//=> [ '1', '3', '5', '7', '9' ] | ||
expand('a..e') | ||
//=> ['a', 'b', 'c', 'd', 'e'] | ||
expand('a..e..2') | ||
//=> ['a', 'c', 'e'] | ||
expand('A..E..2') | ||
//=> ['A', 'C', 'E'] | ||
``` | ||
@@ -78,10 +75,8 @@ | ||
## Related | ||
## Benchmarks | ||
- [micromatch]: wildcard/glob matcher for javascript. a faster alternative to minimatch. | ||
- [fill-range]: the library this depends on for core functionality | ||
- [braces]: this library is used in braces, a fast Brash-like brace expansion lib. | ||
```bash | ||
node benchmark | ||
``` | ||
## Run tests | ||
@@ -113,2 +108,4 @@ | ||
[fill-range]: https://github.com/jonschlinkert/fill-range | ||
[fill-range]: https://github.com/jonschlinkert/fill-range | ||
[micromatch]: https://github.com/jonschlinkert/micromatch | ||
[braces]: https://github.com/jonschlinkert/braces |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4501
27
107
Updatedfill-range@^1.7.1