es-toolkit 1.18.0-dev.581 → 1.18.0-dev.582
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/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +3 -3
- package/dist/compat/index.d.ts +3 -3
- package/dist/compat/index.js +69 -3
- package/dist/compat/index.mjs +3 -3
- package/dist/compat/string/trim.d.mts +15 -0
- package/dist/compat/string/trim.d.ts +15 -0
- package/dist/compat/string/trim.mjs +25 -0
- package/dist/compat/string/trimEnd.d.mts +16 -0
- package/dist/compat/string/trimEnd.d.ts +16 -0
- package/dist/compat/string/trimEnd.mjs +25 -0
- package/dist/{string/ltrim.d.ts → compat/string/trimStart.d.mts} +4 -10
- package/dist/{string/ltrim.d.mts → compat/string/trimStart.d.ts} +4 -10
- package/dist/compat/string/trimStart.mjs +25 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/string/index.d.mts +2 -2
- package/dist/string/index.d.ts +2 -2
- package/dist/string/index.js +44 -22
- package/dist/string/index.mjs +2 -2
- package/dist/string/trim.d.mts +14 -3
- package/dist/string/trim.d.ts +14 -3
- package/dist/string/trim.mjs +8 -5
- package/dist/string/trimEnd.d.mts +16 -0
- package/dist/string/trimEnd.d.ts +16 -0
- package/dist/string/trimEnd.mjs +22 -0
- package/dist/string/trimStart.d.mts +16 -0
- package/dist/string/trimStart.d.ts +16 -0
- package/dist/string/trimStart.mjs +22 -0
- package/package.json +1 -1
- package/dist/string/ltrim.mjs +0 -10
- package/dist/string/rtrim.d.mts +0 -22
- package/dist/string/rtrim.d.ts +0 -22
- package/dist/string/rtrim.mjs +0 -15
package/dist/compat/index.d.mts
CHANGED
|
@@ -95,9 +95,6 @@ export { lowerCase } from '../string/lowerCase.mjs';
|
|
|
95
95
|
export { startCase } from '../string/startCase.mjs';
|
|
96
96
|
export { capitalize } from '../string/capitalize.mjs';
|
|
97
97
|
export { pascalCase } from '../string/pascalCase.mjs';
|
|
98
|
-
export { trim } from '../string/trim.mjs';
|
|
99
|
-
export { ltrim } from '../string/ltrim.mjs';
|
|
100
|
-
export { rtrim } from '../string/rtrim.mjs';
|
|
101
98
|
export { upperFirst } from '../string/upperFirst.mjs';
|
|
102
99
|
export { lowerFirst } from '../string/lowerFirst.mjs';
|
|
103
100
|
export { deburr } from '../string/deburr.mjs';
|
|
@@ -164,6 +161,9 @@ export { endsWith } from './string/endsWith.mjs';
|
|
|
164
161
|
export { padStart } from './string/padStart.mjs';
|
|
165
162
|
export { padEnd } from './string/padEnd.mjs';
|
|
166
163
|
export { repeat } from './string/repeat.mjs';
|
|
164
|
+
export { trim } from './string/trim.mjs';
|
|
165
|
+
export { trimStart } from './string/trimStart.mjs';
|
|
166
|
+
export { trimEnd } from './string/trimEnd.mjs';
|
|
167
167
|
export { max } from './math/max.mjs';
|
|
168
168
|
export { min } from './math/min.mjs';
|
|
169
169
|
export { ceil } from './math/ceil.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -95,9 +95,6 @@ export { lowerCase } from '../string/lowerCase.js';
|
|
|
95
95
|
export { startCase } from '../string/startCase.js';
|
|
96
96
|
export { capitalize } from '../string/capitalize.js';
|
|
97
97
|
export { pascalCase } from '../string/pascalCase.js';
|
|
98
|
-
export { trim } from '../string/trim.js';
|
|
99
|
-
export { ltrim } from '../string/ltrim.js';
|
|
100
|
-
export { rtrim } from '../string/rtrim.js';
|
|
101
98
|
export { upperFirst } from '../string/upperFirst.js';
|
|
102
99
|
export { lowerFirst } from '../string/lowerFirst.js';
|
|
103
100
|
export { deburr } from '../string/deburr.js';
|
|
@@ -164,6 +161,9 @@ export { endsWith } from './string/endsWith.js';
|
|
|
164
161
|
export { padStart } from './string/padStart.js';
|
|
165
162
|
export { padEnd } from './string/padEnd.js';
|
|
166
163
|
export { repeat } from './string/repeat.js';
|
|
164
|
+
export { trim } from './string/trim.js';
|
|
165
|
+
export { trimStart } from './string/trimStart.js';
|
|
166
|
+
export { trimEnd } from './string/trimEnd.js';
|
|
167
167
|
export { max } from './math/max.js';
|
|
168
168
|
export { min } from './math/min.js';
|
|
169
169
|
export { ceil } from './math/ceil.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1060,6 +1060,72 @@ function repeat(str, n) {
|
|
|
1060
1060
|
return str.repeat(n);
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
1063
|
+
function trim(str, chars, guard) {
|
|
1064
|
+
if (str == null) {
|
|
1065
|
+
return '';
|
|
1066
|
+
}
|
|
1067
|
+
if (guard != null || chars == null) {
|
|
1068
|
+
return str.toString().trim();
|
|
1069
|
+
}
|
|
1070
|
+
switch (typeof chars) {
|
|
1071
|
+
case 'string': {
|
|
1072
|
+
return string_index.trim(str, chars.toString().split(''));
|
|
1073
|
+
}
|
|
1074
|
+
case 'object': {
|
|
1075
|
+
if (Array.isArray(chars)) {
|
|
1076
|
+
return string_index.trim(str, chars.map(x => x.toString()));
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
return string_index.trim(str, chars.toString().split(''));
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
function trimStart(str, chars, guard) {
|
|
1086
|
+
if (str == null) {
|
|
1087
|
+
return '';
|
|
1088
|
+
}
|
|
1089
|
+
if (guard != null || chars == null) {
|
|
1090
|
+
return str.toString().trimStart();
|
|
1091
|
+
}
|
|
1092
|
+
switch (typeof chars) {
|
|
1093
|
+
case 'string': {
|
|
1094
|
+
return string_index.trimStart(str, chars.toString().split(''));
|
|
1095
|
+
}
|
|
1096
|
+
case 'object': {
|
|
1097
|
+
if (Array.isArray(chars)) {
|
|
1098
|
+
return string_index.trimStart(str, chars.map(x => x.toString()));
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
return string_index.trimStart(str, chars.toString().split(''));
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function trimEnd(str, chars, guard) {
|
|
1108
|
+
if (str == null) {
|
|
1109
|
+
return '';
|
|
1110
|
+
}
|
|
1111
|
+
if (guard != null || chars == null) {
|
|
1112
|
+
return str.toString().trimEnd();
|
|
1113
|
+
}
|
|
1114
|
+
switch (typeof chars) {
|
|
1115
|
+
case 'string': {
|
|
1116
|
+
return string_index.trimEnd(str, chars.toString().split(''));
|
|
1117
|
+
}
|
|
1118
|
+
case 'object': {
|
|
1119
|
+
if (Array.isArray(chars)) {
|
|
1120
|
+
return string_index.trimEnd(str, chars.map(x => x.toString()));
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
return string_index.trimEnd(str, chars.toString().split(''));
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1063
1129
|
function max(items = []) {
|
|
1064
1130
|
let maxElement = items[0];
|
|
1065
1131
|
let max = undefined;
|
|
@@ -1220,13 +1286,10 @@ exports.escapeRegExp = string_index.escapeRegExp;
|
|
|
1220
1286
|
exports.kebabCase = string_index.kebabCase;
|
|
1221
1287
|
exports.lowerCase = string_index.lowerCase;
|
|
1222
1288
|
exports.lowerFirst = string_index.lowerFirst;
|
|
1223
|
-
exports.ltrim = string_index.ltrim;
|
|
1224
1289
|
exports.pad = string_index.pad;
|
|
1225
1290
|
exports.pascalCase = string_index.pascalCase;
|
|
1226
|
-
exports.rtrim = string_index.rtrim;
|
|
1227
1291
|
exports.snakeCase = string_index.snakeCase;
|
|
1228
1292
|
exports.startCase = string_index.startCase;
|
|
1229
|
-
exports.trim = string_index.trim;
|
|
1230
1293
|
exports.unescape = string_index.unescape;
|
|
1231
1294
|
exports.upperCase = string_index.upperCase;
|
|
1232
1295
|
exports.upperFirst = string_index.upperFirst;
|
|
@@ -1293,4 +1356,7 @@ exports.some = some;
|
|
|
1293
1356
|
exports.sortBy = sortBy;
|
|
1294
1357
|
exports.spread = spread;
|
|
1295
1358
|
exports.startsWith = startsWith;
|
|
1359
|
+
exports.trim = trim;
|
|
1360
|
+
exports.trimEnd = trimEnd;
|
|
1361
|
+
exports.trimStart = trimStart;
|
|
1296
1362
|
exports.zipObjectDeep = zipObjectDeep;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -96,9 +96,6 @@ export { upperCase } from '../string/upperCase.mjs';
|
|
|
96
96
|
export { lowerCase } from '../string/lowerCase.mjs';
|
|
97
97
|
export { startCase } from '../string/startCase.mjs';
|
|
98
98
|
export { pascalCase } from '../string/pascalCase.mjs';
|
|
99
|
-
export { trim } from '../string/trim.mjs';
|
|
100
|
-
export { ltrim } from '../string/ltrim.mjs';
|
|
101
|
-
export { rtrim } from '../string/rtrim.mjs';
|
|
102
99
|
export { upperFirst } from '../string/upperFirst.mjs';
|
|
103
100
|
export { lowerFirst } from '../string/lowerFirst.mjs';
|
|
104
101
|
export { deburr } from '../string/deburr.mjs';
|
|
@@ -164,6 +161,9 @@ export { endsWith } from './string/endsWith.mjs';
|
|
|
164
161
|
export { padStart } from './string/padStart.mjs';
|
|
165
162
|
export { padEnd } from './string/padEnd.mjs';
|
|
166
163
|
export { repeat } from './string/repeat.mjs';
|
|
164
|
+
export { trim } from './string/trim.mjs';
|
|
165
|
+
export { trimStart } from './string/trimStart.mjs';
|
|
166
|
+
export { trimEnd } from './string/trimEnd.mjs';
|
|
167
167
|
export { max } from './math/max.mjs';
|
|
168
168
|
export { min } from './math/min.mjs';
|
|
169
169
|
export { ceil } from './math/ceil.mjs';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes leading and trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which leading and trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
6
|
+
* @returns {string} - The resulting string after the specified leading and trailing characters have been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* trim(" hello "); // "hello"
|
|
10
|
+
* trim("--hello--", "-"); // "hello"
|
|
11
|
+
* trim("##hello##", ["#", "o"]); // "hell"
|
|
12
|
+
*/
|
|
13
|
+
declare function trim(str: string, chars?: string | string[], guard?: unknown): string;
|
|
14
|
+
|
|
15
|
+
export { trim };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes leading and trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which leading and trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
6
|
+
* @returns {string} - The resulting string after the specified leading and trailing characters have been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* trim(" hello "); // "hello"
|
|
10
|
+
* trim("--hello--", "-"); // "hello"
|
|
11
|
+
* trim("##hello##", ["#", "o"]); // "hell"
|
|
12
|
+
*/
|
|
13
|
+
declare function trim(str: string, chars?: string | string[], guard?: unknown): string;
|
|
14
|
+
|
|
15
|
+
export { trim };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { trim as trim$1 } from '../../string/trim.mjs';
|
|
2
|
+
|
|
3
|
+
function trim(str, chars, guard) {
|
|
4
|
+
if (str == null) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
if (guard != null || chars == null) {
|
|
8
|
+
return str.toString().trim();
|
|
9
|
+
}
|
|
10
|
+
switch (typeof chars) {
|
|
11
|
+
case 'string': {
|
|
12
|
+
return trim$1(str, chars.toString().split(''));
|
|
13
|
+
}
|
|
14
|
+
case 'object': {
|
|
15
|
+
if (Array.isArray(chars)) {
|
|
16
|
+
return trim$1(str, chars.map(x => x.toString()));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return trim$1(str, chars.toString().split(''));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { trim };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
6
|
+
* @returns {string} - The resulting string after the specified trailing character has been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
|
|
10
|
+
* const trimmedStr2 = trimEnd('123000', '0') // returns '123'
|
|
11
|
+
* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
|
|
12
|
+
* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
|
|
13
|
+
*/
|
|
14
|
+
declare function trimEnd(str: string, chars?: string | string[], guard?: unknown): string;
|
|
15
|
+
|
|
16
|
+
export { trimEnd };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
6
|
+
* @returns {string} - The resulting string after the specified trailing character has been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
|
|
10
|
+
* const trimmedStr2 = trimEnd('123000', '0') // returns '123'
|
|
11
|
+
* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
|
|
12
|
+
* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
|
|
13
|
+
*/
|
|
14
|
+
declare function trimEnd(str: string, chars?: string | string[], guard?: unknown): string;
|
|
15
|
+
|
|
16
|
+
export { trimEnd };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { trimEnd as trimEnd$1 } from '../../string/trimEnd.mjs';
|
|
2
|
+
|
|
3
|
+
function trimEnd(str, chars, guard) {
|
|
4
|
+
if (str == null) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
if (guard != null || chars == null) {
|
|
8
|
+
return str.toString().trimEnd();
|
|
9
|
+
}
|
|
10
|
+
switch (typeof chars) {
|
|
11
|
+
case 'string': {
|
|
12
|
+
return trimEnd$1(str, chars.toString().split(''));
|
|
13
|
+
}
|
|
14
|
+
case 'object': {
|
|
15
|
+
if (Array.isArray(chars)) {
|
|
16
|
+
return trimEnd$1(str, chars.map(x => x.toString()));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return trimEnd$1(str, chars.toString().split(''));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { trimEnd };
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { TrimParameter } from './trim.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This function removes all leading occurrences of the specified character from the input string.
|
|
7
|
-
* Only the characters at the beginning of the string will be removed.
|
|
2
|
+
* Removes leading whitespace or specified characters from a string.
|
|
8
3
|
*
|
|
9
4
|
* @param {string} str - The string from which leading characters will be trimmed.
|
|
10
|
-
* @param {string}
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
11
6
|
* @returns {string} - The resulting string after the specified leading character has been removed.
|
|
12
7
|
*
|
|
13
8
|
* @example
|
|
@@ -16,7 +11,6 @@ import { TrimParameter } from './trim.js';
|
|
|
16
11
|
* const trimmedStr3 = ltrim('abcabcabc', 'a') // returns 'bcabcabc'
|
|
17
12
|
* const trimmedStr4 = ltrim('xxxtrimmed', 'x') // returns 'trimmed'
|
|
18
13
|
*/
|
|
14
|
+
declare function trimStart(str: string, chars?: string | string[], guard?: unknown): string;
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export { ltrim };
|
|
16
|
+
export { trimStart };
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { TrimParameter } from './trim.mjs';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* This function removes all leading occurrences of the specified character from the input string.
|
|
7
|
-
* Only the characters at the beginning of the string will be removed.
|
|
2
|
+
* Removes leading whitespace or specified characters from a string.
|
|
8
3
|
*
|
|
9
4
|
* @param {string} str - The string from which leading characters will be trimmed.
|
|
10
|
-
* @param {string}
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `" "`.
|
|
11
6
|
* @returns {string} - The resulting string after the specified leading character has been removed.
|
|
12
7
|
*
|
|
13
8
|
* @example
|
|
@@ -16,7 +11,6 @@ import { TrimParameter } from './trim.mjs';
|
|
|
16
11
|
* const trimmedStr3 = ltrim('abcabcabc', 'a') // returns 'bcabcabc'
|
|
17
12
|
* const trimmedStr4 = ltrim('xxxtrimmed', 'x') // returns 'trimmed'
|
|
18
13
|
*/
|
|
14
|
+
declare function trimStart(str: string, chars?: string | string[], guard?: unknown): string;
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export { ltrim };
|
|
16
|
+
export { trimStart };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { trimStart as trimStart$1 } from '../../string/trimStart.mjs';
|
|
2
|
+
|
|
3
|
+
function trimStart(str, chars, guard) {
|
|
4
|
+
if (str == null) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
if (guard != null || chars == null) {
|
|
8
|
+
return str.toString().trimStart();
|
|
9
|
+
}
|
|
10
|
+
switch (typeof chars) {
|
|
11
|
+
case 'string': {
|
|
12
|
+
return trimStart$1(str, chars.toString().split(''));
|
|
13
|
+
}
|
|
14
|
+
case 'object': {
|
|
15
|
+
if (Array.isArray(chars)) {
|
|
16
|
+
return trimStart$1(str, chars.map(x => x.toString()));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return trimStart$1(str, chars.toString().split(''));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { trimStart };
|
package/dist/index.d.mts
CHANGED
|
@@ -121,8 +121,8 @@ export { startCase } from './string/startCase.mjs';
|
|
|
121
121
|
export { capitalize } from './string/capitalize.mjs';
|
|
122
122
|
export { pascalCase } from './string/pascalCase.mjs';
|
|
123
123
|
export { trim } from './string/trim.mjs';
|
|
124
|
-
export {
|
|
125
|
-
export {
|
|
124
|
+
export { trimStart } from './string/trimStart.mjs';
|
|
125
|
+
export { trimEnd } from './string/trimEnd.mjs';
|
|
126
126
|
export { upperFirst } from './string/upperFirst.mjs';
|
|
127
127
|
export { lowerFirst } from './string/lowerFirst.mjs';
|
|
128
128
|
export { deburr } from './string/deburr.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -121,8 +121,8 @@ export { startCase } from './string/startCase.js';
|
|
|
121
121
|
export { capitalize } from './string/capitalize.js';
|
|
122
122
|
export { pascalCase } from './string/pascalCase.js';
|
|
123
123
|
export { trim } from './string/trim.js';
|
|
124
|
-
export {
|
|
125
|
-
export {
|
|
124
|
+
export { trimStart } from './string/trimStart.js';
|
|
125
|
+
export { trimEnd } from './string/trimEnd.js';
|
|
126
126
|
export { upperFirst } from './string/upperFirst.js';
|
|
127
127
|
export { lowerFirst } from './string/lowerFirst.js';
|
|
128
128
|
export { deburr } from './string/deburr.js';
|
package/dist/index.js
CHANGED
|
@@ -141,13 +141,13 @@ exports.escapeRegExp = string_index.escapeRegExp;
|
|
|
141
141
|
exports.kebabCase = string_index.kebabCase;
|
|
142
142
|
exports.lowerCase = string_index.lowerCase;
|
|
143
143
|
exports.lowerFirst = string_index.lowerFirst;
|
|
144
|
-
exports.ltrim = string_index.ltrim;
|
|
145
144
|
exports.pad = string_index.pad;
|
|
146
145
|
exports.pascalCase = string_index.pascalCase;
|
|
147
|
-
exports.rtrim = string_index.rtrim;
|
|
148
146
|
exports.snakeCase = string_index.snakeCase;
|
|
149
147
|
exports.startCase = string_index.startCase;
|
|
150
148
|
exports.trim = string_index.trim;
|
|
149
|
+
exports.trimEnd = string_index.trimEnd;
|
|
150
|
+
exports.trimStart = string_index.trimStart;
|
|
151
151
|
exports.unescape = string_index.unescape;
|
|
152
152
|
exports.upperCase = string_index.upperCase;
|
|
153
153
|
exports.upperFirst = string_index.upperFirst;
|
package/dist/index.mjs
CHANGED
|
@@ -121,8 +121,8 @@ export { startCase } from './string/startCase.mjs';
|
|
|
121
121
|
export { capitalize } from './string/capitalize.mjs';
|
|
122
122
|
export { pascalCase } from './string/pascalCase.mjs';
|
|
123
123
|
export { trim } from './string/trim.mjs';
|
|
124
|
-
export {
|
|
125
|
-
export {
|
|
124
|
+
export { trimStart } from './string/trimStart.mjs';
|
|
125
|
+
export { trimEnd } from './string/trimEnd.mjs';
|
|
126
126
|
export { upperFirst } from './string/upperFirst.mjs';
|
|
127
127
|
export { lowerFirst } from './string/lowerFirst.mjs';
|
|
128
128
|
export { deburr } from './string/deburr.mjs';
|
package/dist/string/index.d.mts
CHANGED
|
@@ -7,8 +7,8 @@ export { startCase } from './startCase.mjs';
|
|
|
7
7
|
export { capitalize } from './capitalize.mjs';
|
|
8
8
|
export { pascalCase } from './pascalCase.mjs';
|
|
9
9
|
export { trim } from './trim.mjs';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
10
|
+
export { trimStart } from './trimStart.mjs';
|
|
11
|
+
export { trimEnd } from './trimEnd.mjs';
|
|
12
12
|
export { upperFirst } from './upperFirst.mjs';
|
|
13
13
|
export { lowerFirst } from './lowerFirst.mjs';
|
|
14
14
|
export { deburr } from './deburr.mjs';
|
package/dist/string/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export { startCase } from './startCase.js';
|
|
|
7
7
|
export { capitalize } from './capitalize.js';
|
|
8
8
|
export { pascalCase } from './pascalCase.js';
|
|
9
9
|
export { trim } from './trim.js';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
10
|
+
export { trimStart } from './trimStart.js';
|
|
11
|
+
export { trimEnd } from './trimEnd.js';
|
|
12
12
|
export { upperFirst } from './upperFirst.js';
|
|
13
13
|
export { lowerFirst } from './lowerFirst.js';
|
|
14
14
|
export { deburr } from './deburr.js';
|
package/dist/string/index.js
CHANGED
|
@@ -69,32 +69,54 @@ function pascalCase(str) {
|
|
|
69
69
|
return words.map(word => capitalize(word)).join('');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
while ((chars[startHere] === toTrim || toTrim.includes(chars[startHere])) && startHere < chars.length) {
|
|
76
|
-
startHere++;
|
|
72
|
+
function trimStart(str, chars) {
|
|
73
|
+
if (chars == null) {
|
|
74
|
+
return str.trimStart();
|
|
77
75
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (typeof toTrim === 'string' ? lastChar === toTrim : toTrim.includes(lastChar)) {
|
|
86
|
-
chars.pop();
|
|
76
|
+
let startIndex = 0;
|
|
77
|
+
switch (typeof chars) {
|
|
78
|
+
case 'string': {
|
|
79
|
+
while (startIndex < str.length && str[startIndex] === chars) {
|
|
80
|
+
startIndex++;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
87
83
|
}
|
|
88
|
-
|
|
84
|
+
case 'object': {
|
|
85
|
+
while (startIndex < str.length && chars.includes(str[startIndex])) {
|
|
86
|
+
startIndex++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return str.substring(startIndex);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function trimEnd(str, chars) {
|
|
94
|
+
if (chars == null) {
|
|
95
|
+
return str.trimEnd();
|
|
96
|
+
}
|
|
97
|
+
let endIndex = str.length;
|
|
98
|
+
switch (typeof chars) {
|
|
99
|
+
case 'string': {
|
|
100
|
+
while (endIndex > 0 && str[endIndex - 1] === chars) {
|
|
101
|
+
endIndex--;
|
|
102
|
+
}
|
|
89
103
|
break;
|
|
90
104
|
}
|
|
105
|
+
case 'object': {
|
|
106
|
+
while (endIndex > 0 && chars.includes(str[endIndex - 1])) {
|
|
107
|
+
endIndex--;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
91
110
|
}
|
|
92
|
-
return
|
|
93
|
-
}
|
|
111
|
+
return str.substring(0, endIndex);
|
|
112
|
+
}
|
|
94
113
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
function trim(str, chars) {
|
|
115
|
+
if (chars == null) {
|
|
116
|
+
return str.trim();
|
|
117
|
+
}
|
|
118
|
+
return trimStart(trimEnd(str, chars), chars);
|
|
119
|
+
}
|
|
98
120
|
|
|
99
121
|
function upperFirst(str) {
|
|
100
122
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
@@ -186,13 +208,13 @@ exports.escapeRegExp = escapeRegExp;
|
|
|
186
208
|
exports.kebabCase = kebabCase;
|
|
187
209
|
exports.lowerCase = lowerCase;
|
|
188
210
|
exports.lowerFirst = lowerFirst;
|
|
189
|
-
exports.ltrim = ltrim;
|
|
190
211
|
exports.pad = pad;
|
|
191
212
|
exports.pascalCase = pascalCase;
|
|
192
|
-
exports.rtrim = rtrim;
|
|
193
213
|
exports.snakeCase = snakeCase;
|
|
194
214
|
exports.startCase = startCase;
|
|
195
215
|
exports.trim = trim;
|
|
216
|
+
exports.trimEnd = trimEnd;
|
|
217
|
+
exports.trimStart = trimStart;
|
|
196
218
|
exports.unescape = unescape;
|
|
197
219
|
exports.upperCase = upperCase;
|
|
198
220
|
exports.upperFirst = upperFirst;
|
package/dist/string/index.mjs
CHANGED
|
@@ -7,8 +7,8 @@ export { startCase } from './startCase.mjs';
|
|
|
7
7
|
export { capitalize } from './capitalize.mjs';
|
|
8
8
|
export { pascalCase } from './pascalCase.mjs';
|
|
9
9
|
export { trim } from './trim.mjs';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
10
|
+
export { trimStart } from './trimStart.mjs';
|
|
11
|
+
export { trimEnd } from './trimEnd.mjs';
|
|
12
12
|
export { upperFirst } from './upperFirst.mjs';
|
|
13
13
|
export { lowerFirst } from './lowerFirst.mjs';
|
|
14
14
|
export { deburr } from './deburr.mjs';
|
package/dist/string/trim.d.mts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Removes leading and trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the string. Can be a single character or an array of characters.
|
|
6
|
+
* @returns {string} - The resulting string after the specified characters have been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* trim(" hello "); // "hello"
|
|
10
|
+
* trim("--hello--", "-"); // "hello"
|
|
11
|
+
* trim("##hello##", ["#", "o"]); // "hell"
|
|
12
|
+
*/
|
|
13
|
+
declare function trim(str: string, chars?: string | string[]): string;
|
|
3
14
|
|
|
4
|
-
export {
|
|
15
|
+
export { trim };
|
package/dist/string/trim.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Removes leading and trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the string. Can be a single character or an array of characters.
|
|
6
|
+
* @returns {string} - The resulting string after the specified characters have been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* trim(" hello "); // "hello"
|
|
10
|
+
* trim("--hello--", "-"); // "hello"
|
|
11
|
+
* trim("##hello##", ["#", "o"]); // "hell"
|
|
12
|
+
*/
|
|
13
|
+
declare function trim(str: string, chars?: string | string[]): string;
|
|
3
14
|
|
|
4
|
-
export {
|
|
15
|
+
export { trim };
|
package/dist/string/trim.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { trimStart } from './trimStart.mjs';
|
|
2
|
+
import { trimEnd } from './trimEnd.mjs';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function trim(str, chars) {
|
|
5
|
+
if (chars == null) {
|
|
6
|
+
return str.trim();
|
|
7
|
+
}
|
|
8
|
+
return trimStart(trimEnd(str, chars), chars);
|
|
9
|
+
}
|
|
7
10
|
|
|
8
11
|
export { trim };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string.
|
|
6
|
+
* @returns {string} - The resulting string after the specified trailing character has been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
|
|
10
|
+
* const trimmedStr2 = trimEnd('123000', '0') // returns '123'
|
|
11
|
+
* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
|
|
12
|
+
* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
|
|
13
|
+
*/
|
|
14
|
+
declare function trimEnd(str: string, chars?: string | string[]): string;
|
|
15
|
+
|
|
16
|
+
export { trimEnd };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace or specified characters from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} str - The string from which trailing characters will be trimmed.
|
|
5
|
+
* @param {string | string[]} chars - The character(s) to remove from the end of the string.
|
|
6
|
+
* @returns {string} - The resulting string after the specified trailing character has been removed.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'
|
|
10
|
+
* const trimmedStr2 = trimEnd('123000', '0') // returns '123'
|
|
11
|
+
* const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'
|
|
12
|
+
* const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'
|
|
13
|
+
*/
|
|
14
|
+
declare function trimEnd(str: string, chars?: string | string[]): string;
|
|
15
|
+
|
|
16
|
+
export { trimEnd };
|