You've already forked codtracker-js
format: prettify entire project
This commit is contained in:
22
node_modules/to-regex-range/index.js
generated
vendored
22
node_modules/to-regex-range/index.js
generated
vendored
@ -11,7 +11,9 @@ const isNumber = require('is-number');
|
||||
|
||||
const toRegexRange = (min, max, options) => {
|
||||
if (isNumber(min) === false) {
|
||||
throw new TypeError('toRegexRange: expected the first argument to be a number');
|
||||
throw new TypeError(
|
||||
'toRegexRange: expected the first argument to be a number'
|
||||
);
|
||||
}
|
||||
|
||||
if (max === void 0 || min === max) {
|
||||
@ -19,7 +21,9 @@ const toRegexRange = (min, max, options) => {
|
||||
}
|
||||
|
||||
if (isNumber(max) === false) {
|
||||
throw new TypeError('toRegexRange: expected the second argument to be a number.');
|
||||
throw new TypeError(
|
||||
'toRegexRange: expected the second argument to be a number.'
|
||||
);
|
||||
}
|
||||
|
||||
let opts = { relaxZeros: true, ...options };
|
||||
@ -77,7 +81,7 @@ const toRegexRange = (min, max, options) => {
|
||||
|
||||
if (opts.capture === true) {
|
||||
state.result = `(${state.result})`;
|
||||
} else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
|
||||
} else if (opts.wrap !== false && positives.length + negatives.length > 1) {
|
||||
state.result = `(?:${state.result})`;
|
||||
}
|
||||
|
||||
@ -141,10 +145,8 @@ function rangeToPattern(start, stop, options) {
|
||||
|
||||
if (startDigit === stopDigit) {
|
||||
pattern += startDigit;
|
||||
|
||||
} else if (startDigit !== '0' || stopDigit !== '9') {
|
||||
pattern += toCharacterClass(startDigit, stopDigit, options);
|
||||
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
@ -222,11 +224,15 @@ function zip(a, b) {
|
||||
}
|
||||
|
||||
function compare(a, b) {
|
||||
return a > b ? 1 : b > a ? -1 : 0;
|
||||
return (
|
||||
a > b ? 1
|
||||
: b > a ? -1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
function contains(arr, key, val) {
|
||||
return arr.some(ele => ele[key] === val);
|
||||
return arr.some((ele) => ele[key] === val);
|
||||
}
|
||||
|
||||
function countNines(min, len) {
|
||||
@ -246,7 +252,7 @@ function toQuantifier(digits) {
|
||||
}
|
||||
|
||||
function toCharacterClass(a, b, options) {
|
||||
return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
|
||||
return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
|
||||
}
|
||||
|
||||
function hasPadding(str) {
|
||||
|
Reference in New Issue
Block a user