es-toolkit 1.9.0-dev.173 → 1.9.0-dev.175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +14 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +37 -33
- package/dist/array/toFilled.d.mts +33 -0
- package/dist/array/toFilled.d.ts +33 -0
- package/dist/array/toFilled.js +40 -0
- package/dist/array/toFilled.js.map +1 -0
- package/dist/array/toFilled.mjs +8 -0
- package/dist/chunk-2M3YVRFS.mjs +1 -0
- package/dist/chunk-2M3YVRFS.mjs.map +1 -0
- package/dist/chunk-NLN3GQ7D.mjs +1 -0
- package/dist/chunk-NLN3GQ7D.mjs.map +1 -0
- package/dist/chunk-OP4OAKQJ.mjs +16 -0
- package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
- package/dist/chunk-T5URDZEQ.mjs +7 -0
- package/dist/chunk-T5URDZEQ.mjs.map +1 -0
- package/dist/chunk-VRFIBW4H.mjs +14 -0
- package/dist/chunk-VRFIBW4H.mjs.map +1 -0
- package/dist/chunk-YOFIBRET.mjs +1 -0
- package/dist/chunk-YOFIBRET.mjs.map +1 -0
- package/dist/constants/caseSplitPattern.d.mts +19 -0
- package/dist/constants/caseSplitPattern.d.ts +19 -0
- package/dist/constants/caseSplitPattern.js +31 -0
- package/dist/constants/caseSplitPattern.js.map +1 -0
- package/dist/constants/caseSplitPattern.mjs +8 -0
- package/dist/constants/caseSplitPattern.mjs.map +1 -0
- package/dist/constants/index.d.mts +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +33 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/index.mjs +9 -0
- package/dist/constants/index.mjs.map +1 -0
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -51
- package/dist/math/index.mjs +3 -3
- package/dist/object/index.mjs +6 -6
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +39 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +11 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/snakeCase.d.mts +17 -0
- package/dist/string/snakeCase.d.ts +17 -0
- package/dist/string/snakeCase.js +39 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/snakeCase.mjs +10 -0
- package/dist/string/snakeCase.mjs.map +1 -0
- package/package.json +21 -1
- package/string.d.ts +1 -0
- package/dist/chunk-WGIVYA3P.mjs +0 -1
- /package/dist/{chunk-WGIVYA3P.mjs.map → array/toFilled.mjs.map} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/array/toFilled.ts
|
|
21
|
+
var toFilled_exports = {};
|
|
22
|
+
__export(toFilled_exports, {
|
|
23
|
+
toFilled: () => toFilled
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(toFilled_exports);
|
|
26
|
+
function toFilled(arr, value, start = 0, end = arr.length) {
|
|
27
|
+
const length = arr.length;
|
|
28
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
29
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
30
|
+
const newArr = arr.slice();
|
|
31
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
32
|
+
newArr[i] = value;
|
|
33
|
+
}
|
|
34
|
+
return newArr;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
toFilled
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=toFilled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,SAAS,SAAe,KAAU,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AAC5F,QAAM,SAAS,IAAI;AACnB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,QAAM,SAAuB,IAAI,MAAM;AAEvC,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,WAAO,CAAC,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-2M3YVRFS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-NLN3GQ7D.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/array/toFilled.ts
|
|
2
|
+
function toFilled(arr, value, start = 0, end = arr.length) {
|
|
3
|
+
const length = arr.length;
|
|
4
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
5
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
6
|
+
const newArr = arr.slice();
|
|
7
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
8
|
+
newArr[i] = value;
|
|
9
|
+
}
|
|
10
|
+
return newArr;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
toFilled
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-OP4OAKQJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";AAgCO,SAAS,SAAe,KAAU,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AAC5F,QAAM,SAAS,IAAI;AACnB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,QAAM,SAAuB,IAAI,MAAM;AAEvC,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,WAAO,CAAC,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants/caseSplitPattern.ts"],"sourcesContent":["/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\n\nexport const CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;\n"],"mappings":";AAiBO,IAAM,qBAAqB;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CASE_SPLIT_PATTERN
|
|
3
|
+
} from "./chunk-T5URDZEQ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/snakeCase.ts
|
|
6
|
+
var snakeCase = (str) => {
|
|
7
|
+
const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
|
|
8
|
+
return splitWords.map((word) => word.toLowerCase()).join("_");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
snakeCase
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-VRFIBW4H.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/snakeCase.ts"],"sourcesContent":["import { CASE_SPLIT_PATTERN } from '../constants';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const splitWords = str.match(CASE_SPLIT_PATTERN) || [];\n return splitWords.map(word => word.toLowerCase()).join('_');\n};\n"],"mappings":";;;;;AAiBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,aAAa,IAAI,MAAM,kBAAkB,KAAK,CAAC;AACrD,SAAO,WAAW,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AAC5D;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-YOFIBRET.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regular expression pattern to split strings into words for various case conversions
|
|
3
|
+
*
|
|
4
|
+
* This pattern matchs sequences of characters in a string, considering the following case:
|
|
5
|
+
* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
|
|
6
|
+
* - Sequences of one uppercase letter optionally followed by lowercase letters and digits
|
|
7
|
+
* - Single uppercase letters
|
|
8
|
+
* - Sequences of digis
|
|
9
|
+
*
|
|
10
|
+
* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
|
|
11
|
+
* a consistent format like snake case.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
|
|
15
|
+
* // matchs: ['camel', 'Case', 'HTTP', 'Request']
|
|
16
|
+
*/
|
|
17
|
+
declare const CASE_SPLIT_PATTERN: RegExp;
|
|
18
|
+
|
|
19
|
+
export { CASE_SPLIT_PATTERN };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regular expression pattern to split strings into words for various case conversions
|
|
3
|
+
*
|
|
4
|
+
* This pattern matchs sequences of characters in a string, considering the following case:
|
|
5
|
+
* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)
|
|
6
|
+
* - Sequences of one uppercase letter optionally followed by lowercase letters and digits
|
|
7
|
+
* - Single uppercase letters
|
|
8
|
+
* - Sequences of digis
|
|
9
|
+
*
|
|
10
|
+
* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into
|
|
11
|
+
* a consistent format like snake case.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);
|
|
15
|
+
* // matchs: ['camel', 'Case', 'HTTP', 'Request']
|
|
16
|
+
*/
|
|
17
|
+
declare const CASE_SPLIT_PATTERN: RegExp;
|
|
18
|
+
|
|
19
|
+
export { CASE_SPLIT_PATTERN };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/constants/caseSplitPattern.ts
|
|
21
|
+
var caseSplitPattern_exports = {};
|
|
22
|
+
__export(caseSplitPattern_exports, {
|
|
23
|
+
CASE_SPLIT_PATTERN: () => CASE_SPLIT_PATTERN
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(caseSplitPattern_exports);
|
|
26
|
+
var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
CASE_SPLIT_PATTERN
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=caseSplitPattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/caseSplitPattern.ts"],"sourcesContent":["/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\n\nexport const CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,IAAM,qBAAqB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CASE_SPLIT_PATTERN } from './caseSplitPattern.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CASE_SPLIT_PATTERN } from './caseSplitPattern.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/constants/index.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
CASE_SPLIT_PATTERN: () => CASE_SPLIT_PATTERN
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
|
|
27
|
+
// src/constants/caseSplitPattern.ts
|
|
28
|
+
var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
CASE_SPLIT_PATTERN
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/index.ts","../../src/constants/caseSplitPattern.ts"],"sourcesContent":["export { CASE_SPLIT_PATTERN } from './caseSplitPattern';\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\n\nexport const CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,qBAAqB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/function/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../chunk-N6EM6ETS.mjs";
|
|
2
|
-
import {
|
|
3
|
-
debounce
|
|
4
|
-
} from "../chunk-3IP4JVLL.mjs";
|
|
5
|
-
import {
|
|
6
|
-
noop
|
|
7
|
-
} from "../chunk-LKXCOLNY.mjs";
|
|
8
2
|
import {
|
|
9
3
|
once
|
|
10
4
|
} from "../chunk-CMBC4MXG.mjs";
|
|
11
5
|
import {
|
|
12
6
|
throttle
|
|
13
7
|
} from "../chunk-QOJGMVVR.mjs";
|
|
8
|
+
import {
|
|
9
|
+
debounce
|
|
10
|
+
} from "../chunk-3IP4JVLL.mjs";
|
|
11
|
+
import {
|
|
12
|
+
noop
|
|
13
|
+
} from "../chunk-LKXCOLNY.mjs";
|
|
14
14
|
import "../chunk-2MM5EJJX.mjs";
|
|
15
15
|
export {
|
|
16
16
|
debounce,
|
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,7 @@ export { zipWith } from './array/zipWith.mjs';
|
|
|
44
44
|
export { without } from './array/without.mjs';
|
|
45
45
|
export { head } from './array/head.mjs';
|
|
46
46
|
export { tail } from './array/tail.mjs';
|
|
47
|
+
export { toFilled } from './array/toFilled.mjs';
|
|
47
48
|
export { last } from './array/last.mjs';
|
|
48
49
|
export { AbortError } from './error/AbortError.mjs';
|
|
49
50
|
export { debounce } from './function/debounce.mjs';
|
|
@@ -69,3 +70,4 @@ export { isNotNil } from './predicate/isNotNil.mjs';
|
|
|
69
70
|
export { isNull } from './predicate/isNull.mjs';
|
|
70
71
|
export { isUndefined } from './predicate/isUndefined.mjs';
|
|
71
72
|
export { delay } from './promise/delay.mjs';
|
|
73
|
+
export { snakeCase } from './string/snakeCase.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export { zipWith } from './array/zipWith.js';
|
|
|
44
44
|
export { without } from './array/without.js';
|
|
45
45
|
export { head } from './array/head.js';
|
|
46
46
|
export { tail } from './array/tail.js';
|
|
47
|
+
export { toFilled } from './array/toFilled.js';
|
|
47
48
|
export { last } from './array/last.js';
|
|
48
49
|
export { AbortError } from './error/AbortError.js';
|
|
49
50
|
export { debounce } from './function/debounce.js';
|
|
@@ -69,3 +70,4 @@ export { isNotNil } from './predicate/isNotNil.js';
|
|
|
69
70
|
export { isNull } from './predicate/isNull.js';
|
|
70
71
|
export { isUndefined } from './predicate/isUndefined.js';
|
|
71
72
|
export { delay } from './promise/delay.js';
|
|
73
|
+
export { snakeCase } from './string/snakeCase.js';
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ __export(src_exports, {
|
|
|
83
83
|
sample: () => sample,
|
|
84
84
|
sampleSize: () => sampleSize,
|
|
85
85
|
shuffle: () => shuffle,
|
|
86
|
+
snakeCase: () => snakeCase,
|
|
86
87
|
sum: () => sum,
|
|
87
88
|
tail: () => tail,
|
|
88
89
|
take: () => take,
|
|
@@ -90,6 +91,7 @@ __export(src_exports, {
|
|
|
90
91
|
takeRightWhile: () => takeRightWhile,
|
|
91
92
|
takeWhile: () => takeWhile,
|
|
92
93
|
throttle: () => throttle,
|
|
94
|
+
toFilled: () => toFilled,
|
|
93
95
|
union: () => union,
|
|
94
96
|
unionBy: () => unionBy,
|
|
95
97
|
unionWith: () => unionWith,
|
|
@@ -590,6 +592,18 @@ function tail(arr) {
|
|
|
590
592
|
return result;
|
|
591
593
|
}
|
|
592
594
|
|
|
595
|
+
// src/array/toFilled.ts
|
|
596
|
+
function toFilled(arr, value, start = 0, end = arr.length) {
|
|
597
|
+
const length = arr.length;
|
|
598
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
599
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
600
|
+
const newArr = arr.slice();
|
|
601
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
602
|
+
newArr[i] = value;
|
|
603
|
+
}
|
|
604
|
+
return newArr;
|
|
605
|
+
}
|
|
606
|
+
|
|
593
607
|
// src/array/last.ts
|
|
594
608
|
function last(arr) {
|
|
595
609
|
return arr[arr.length - 1];
|
|
@@ -821,6 +835,15 @@ function delay(ms, { signal } = {}) {
|
|
|
821
835
|
signal == null ? void 0 : signal.addEventListener("abort", abortHandler, { once: true });
|
|
822
836
|
});
|
|
823
837
|
}
|
|
838
|
+
|
|
839
|
+
// src/constants/caseSplitPattern.ts
|
|
840
|
+
var CASE_SPLIT_PATTERN = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;
|
|
841
|
+
|
|
842
|
+
// src/string/snakeCase.ts
|
|
843
|
+
var snakeCase = (str) => {
|
|
844
|
+
const splitWords = str.match(CASE_SPLIT_PATTERN) || [];
|
|
845
|
+
return splitWords.map((word) => word.toLowerCase()).join("_");
|
|
846
|
+
};
|
|
824
847
|
// Annotate the CommonJS export names for ESM import in node:
|
|
825
848
|
0 && (module.exports = {
|
|
826
849
|
AbortError,
|
|
@@ -872,6 +895,7 @@ function delay(ms, { signal } = {}) {
|
|
|
872
895
|
sample,
|
|
873
896
|
sampleSize,
|
|
874
897
|
shuffle,
|
|
898
|
+
snakeCase,
|
|
875
899
|
sum,
|
|
876
900
|
tail,
|
|
877
901
|
take,
|
|
@@ -879,6 +903,7 @@ function delay(ms, { signal } = {}) {
|
|
|
879
903
|
takeRightWhile,
|
|
880
904
|
takeWhile,
|
|
881
905
|
throttle,
|
|
906
|
+
toFilled,
|
|
882
907
|
union,
|
|
883
908
|
unionBy,
|
|
884
909
|
unionWith,
|