to-regex-range
Advanced tools
Comparing version 0.1.3 to 0.2.0
27
index.js
@@ -32,5 +32,10 @@ /*! | ||
var a = +min; | ||
var b = +max; | ||
var a = min; | ||
var b = max; | ||
if (min > 0 && max > 0) { | ||
a = Math.min(min, max); | ||
b = Math.max(min, max); | ||
} | ||
if (a === b) { | ||
@@ -44,19 +49,19 @@ return a; | ||
min = min.toString(); | ||
max = max.toString(); | ||
a = String(a); | ||
b = String(b); | ||
var positives = []; | ||
var negatives = []; | ||
if (min < 0) { | ||
if (a < 0) { | ||
var newMin = 1; | ||
if (max < 0) { | ||
newMin = Math.abs(max); | ||
if (b < 0) { | ||
newMin = Math.abs(b); | ||
} | ||
var newMax = Math.abs(min); | ||
var newMax = Math.abs(a); | ||
negatives = splitToPatterns(newMin, newMax); | ||
min = 0; | ||
a = 0; | ||
} | ||
if (max >= 0) { | ||
positives = splitToPatterns(min, max); | ||
if (b >= 0) { | ||
positives = splitToPatterns(a, b); | ||
} | ||
@@ -63,0 +68,0 @@ |
{ | ||
"name": "to-regex-range", | ||
"description": "Returns a regex-compatible range from two numbers, min and max, with 855,412 generated unit tests to validate it's accuracy! Useful for creating regular expressions to validate numbers, ranges, years, etc. Returns a string, allowing the returned value to be used in regular expressions generated by other libraries.", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/to-regex-range", | ||
@@ -28,4 +28,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"gulp-format-md": "^0.1.9", | ||
"mocha": "^2.4.5", | ||
"should": "^8.3.1" | ||
"mocha": "^2.4.5" | ||
}, | ||
@@ -32,0 +31,0 @@ "keywords": [ |
# to-regex-range [![NPM version](https://img.shields.io/npm/v/to-regex-range.svg?style=flat)](https://www.npmjs.com/package/to-regex-range) [![NPM downloads](https://img.shields.io/npm/dm/to-regex-range.svg?style=flat)](https://npmjs.org/package/to-regex-range) [![Build Status](https://img.shields.io/travis/jonschlinkert/to-regex-range.svg?style=flat)](https://travis-ci.org/jonschlinkert/to-regex-range) | ||
> Returns a regex-compatible range from two numbers, min and max, with 850,000 generated unit tests to validate it's accuracy! Useful for creating regular expressions to validate numbers, ranges, years, etc. Returns a string, allowing the returned value to be used in regular expressions generated by other libraries. | ||
> Returns a regex-compatible range from two numbers, min and max, with 855,412 generated unit tests to validate it's accuracy! Useful for creating regular expressions to validate numbers, ranges, years, etc. Returns a string, allowing the returned value to be used in regular expressions generated by other libraries. | ||
@@ -5,0 +5,0 @@ ## Install |
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
11742
2
175