fill-range
Advanced tools
Comparing version 1.4.0 to 1.5.0
56
index.js
@@ -52,21 +52,21 @@ /*! | ||
var match = stepRe().exec(step); | ||
var i = match && match.index; | ||
if (match) { | ||
var i = match.index; | ||
if (match && match[0] === '+') { | ||
return repeat(a, b); | ||
if (match[0] === '+') { | ||
return repeat(a, b); | ||
} else if (match && match[0] === '?') { | ||
return [randomize(a, b)]; | ||
} else if (match[0] === '?') { | ||
return [randomize(a, b)]; | ||
} else if (match && match[0] === '>') { | ||
step = step.substr(0, i) + step.substr(i + 1); | ||
expand = true; | ||
} else if (match[0] === '>') { | ||
step = step.substr(0, i) + step.substr(i + 1); | ||
expand = true; | ||
} else if (match && match[0] === '|') { | ||
step = step.substr(0, i) + step.substr(i + 1); | ||
expand = true; | ||
sep = '|'; | ||
} | ||
if (!match && !isNumber(step)) { | ||
} else if (match[0] === '|') { | ||
step = step.substr(0, i) + step.substr(i + 1); | ||
expand = true; | ||
sep = '|'; | ||
} | ||
} else if (!isNumber(step)) { | ||
throw new TypeError('fill-range: invalid step.'); | ||
@@ -76,3 +76,4 @@ } | ||
if (!hasEither(a) || !hasEither(b) || hasBoth(a) || hasBoth(b)) { | ||
// has neither a letter nor number, or has both letters and numbers | ||
if (!noAlphaNum(a) || !noAlphaNum(b) || hasBoth(a) || hasBoth(b)) { | ||
throw new Error('fill-range: invalid range arguments.'); | ||
@@ -89,2 +90,6 @@ } | ||
// by this point both are the same, so we | ||
// can use A to check going forward. | ||
var isNum = isNumA; | ||
var num = step && isNumber(step) | ||
@@ -95,9 +100,12 @@ ? Math.abs(step) | ||
// is the range alphabetical? or numeric? | ||
var isNum = isNumber(a); | ||
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); | ||
} | ||
// if numeric coerce to an integer, otherwise | ||
// get the charCode to expand alpha ranges | ||
a = isNum ? +a : a.charCodeAt(0); | ||
b = isNum ? +b : b.charCodeAt(0); | ||
// is the pattern positive or negative? | ||
@@ -160,3 +168,3 @@ var isNegative = b < a; | ||
function hasEither(val) { | ||
function noAlphaNum(val) { | ||
return /[a-z0-9]/i.test(val); | ||
@@ -179,3 +187,3 @@ } | ||
function zeros(val) { | ||
if (/^-*0+$/.test(val)) { | ||
if (/^-*0+$/.test(val.toString())) { | ||
return '0'; | ||
@@ -182,0 +190,0 @@ } |
{ | ||
"name": "fill-range", | ||
"description": "Fill in a range of numbers or letters, optionally passing an increment or multiplier to use.", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"homepage": "https://github.com/jonschlinkert/fill-range", | ||
@@ -25,12 +25,12 @@ "author": { | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "mocha -R spec", | ||
"docs": "update && license && npmignore && deps && verb", | ||
"all": "npm run test && npm run docs" | ||
"test": "mocha -R spec" | ||
}, | ||
"dependencies": { | ||
"is-number": "^0.1.1", | ||
"is-number": "^1.1.0", | ||
"randomatic": "^1.0.1", | ||
"repeat-element": "^1.0.0", | ||
"repeat-string": "^1.2.0" | ||
"repeat-element": "^1.0.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -11,8 +11,2 @@ # fill-range [![NPM version](https://badge.fury.io/js/fill-range.svg)](http://badge.fury.io/js/fill-range) | ||
## Run tests | ||
```bash | ||
npm test | ||
``` | ||
## Usage | ||
@@ -173,2 +167,11 @@ | ||
## Run tests | ||
Install dev dependencies: | ||
```bash | ||
npm i -d && npm test | ||
``` | ||
## Contributing | ||
@@ -190,4 +193,4 @@ Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/fill-range/issues) | ||
_This file was generated by [verb](https://github.com/assemble/verb) on January 14, 2015._ | ||
_This file was generated by [verb](https://github.com/assemble/verb) on January 24, 2015._ | ||
[randomatic]: https://github.com/jonschlinkert/randomatic |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3
193
0
9614
3
189
+ Addedis-number@1.1.2(transitive)
- Removedrepeat-string@^1.2.0
- Removedis-number@0.1.1(transitive)
- Removedrepeat-string@1.6.1(transitive)
Updatedis-number@^1.1.0