format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

65
node_modules/fill-range/index.js generated vendored
View File

@ -10,19 +10,22 @@
const util = require('util');
const toRegexRange = require('to-regex-range');
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
const isObject = (val) =>
val !== null && typeof val === 'object' && !Array.isArray(val);
const transform = toNumber => {
return value => toNumber === true ? Number(value) : String(value);
const transform = (toNumber) => {
return (value) => (toNumber === true ? Number(value) : String(value));
};
const isValidValue = value => {
return typeof value === 'number' || (typeof value === 'string' && value !== '');
const isValidValue = (value) => {
return (
typeof value === 'number' || (typeof value === 'string' && value !== '')
);
};
const isNumber = num => Number.isInteger(+num);
const isNumber = (num) => Number.isInteger(+num);
const zeros = input => {
const zeros = (input) => {
let value = `${input}`;
let index = -1;
if (value[0] === '-') value = value.slice(1);
@ -42,7 +45,7 @@ const pad = (input, maxLength, toNumber) => {
if (maxLength > 0) {
let dash = input[0] === '-' ? '-' : '';
if (dash) input = input.slice(1);
input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
}
if (toNumber === false) {
return String(input);
@ -57,12 +60,20 @@ const toMaxLen = (input, maxLength) => {
maxLength--;
}
while (input.length < maxLength) input = '0' + input;
return negative ? ('-' + input) : input;
return negative ? '-' + input : input;
};
const toSequence = (parts, options, maxLen) => {
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
parts.negatives.sort((a, b) =>
a < b ? -1
: a > b ? 1
: 0
);
parts.positives.sort((a, b) =>
a < b ? -1
: a > b ? 1
: 0
);
let prefix = options.capture ? '' : '?:';
let positives = '';
@ -70,11 +81,13 @@ const toSequence = (parts, options, maxLen) => {
let result;
if (parts.positives.length) {
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
positives = parts.positives
.map((v) => toMaxLen(String(v), maxLen))
.join('|');
}
if (parts.negatives.length) {
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
negatives = `-(${prefix}${parts.negatives.map((v) => toMaxLen(String(v), maxLen)).join('|')})`;
}
if (positives && negatives) {
@ -147,16 +160,25 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
step = Math.max(Math.abs(step), 1);
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
let maxLen =
padded ?
Math.max(startString.length, endString.length, stepString.length)
: 0;
let toNumber = padded === false && stringify(start, end, options) === false;
let format = options.transform || transform(toNumber);
if (options.toRegex && step === 1) {
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
return toRange(
toMaxLen(start, maxLen),
toMaxLen(end, maxLen),
true,
options
);
}
let parts = { negatives: [], positives: [] };
let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
let push = (num) =>
parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
let range = [];
let index = 0;
@ -171,8 +193,8 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
}
if (options.toRegex === true) {
return step > 1
? toSequence(parts, options, maxLen)
return step > 1 ?
toSequence(parts, options, maxLen)
: toRegex(range, null, { wrap: false, ...options });
}
@ -180,11 +202,14 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
};
const fillLetters = (start, end, step = 1, options = {}) => {
if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
if (
(!isNumber(start) && start.length > 1) ||
(!isNumber(end) && end.length > 1)
) {
return invalidRange(start, end, options);
}
let format = options.transform || (val => String.fromCharCode(val));
let format = options.transform || ((val) => String.fromCharCode(val));
let a = `${start}`.charCodeAt(0);
let b = `${end}`.charCodeAt(0);