es-toolkit 1.20.0-dev.656 → 1.20.0-dev.658
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 +1 -1
- package/dist/compat/index.d.ts +1 -1
- package/dist/compat/index.js +5 -1
- package/dist/compat/index.mjs +1 -1
- package/dist/compat/string/pad.d.mts +19 -0
- package/dist/compat/string/pad.d.ts +19 -0
- package/dist/compat/string/pad.mjs +8 -0
- package/dist/string/index.js +1 -6
- package/dist/string/startCase.d.mts +1 -1
- package/dist/string/startCase.d.ts +1 -1
- package/dist/string/startCase.mjs +1 -6
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -89,7 +89,6 @@ export { deburr } from '../string/deburr.mjs';
|
|
|
89
89
|
export { escape } from '../string/escape.mjs';
|
|
90
90
|
export { escapeRegExp } from '../string/escapeRegExp.mjs';
|
|
91
91
|
export { unescape } from '../string/unescape.mjs';
|
|
92
|
-
export { pad } from '../string/pad.mjs';
|
|
93
92
|
export { castArray } from './array/castArray.mjs';
|
|
94
93
|
export { chunk } from './array/chunk.mjs';
|
|
95
94
|
export { concat } from './array/concat.mjs';
|
|
@@ -167,6 +166,7 @@ export { lowerCase } from './string/lowerCase.mjs';
|
|
|
167
166
|
export { upperCase } from './string/upperCase.mjs';
|
|
168
167
|
export { startsWith } from './string/startsWith.mjs';
|
|
169
168
|
export { endsWith } from './string/endsWith.mjs';
|
|
169
|
+
export { pad } from './string/pad.mjs';
|
|
170
170
|
export { padStart } from './string/padStart.mjs';
|
|
171
171
|
export { padEnd } from './string/padEnd.mjs';
|
|
172
172
|
export { repeat } from './string/repeat.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -89,7 +89,6 @@ export { deburr } from '../string/deburr.js';
|
|
|
89
89
|
export { escape } from '../string/escape.js';
|
|
90
90
|
export { escapeRegExp } from '../string/escapeRegExp.js';
|
|
91
91
|
export { unescape } from '../string/unescape.js';
|
|
92
|
-
export { pad } from '../string/pad.js';
|
|
93
92
|
export { castArray } from './array/castArray.js';
|
|
94
93
|
export { chunk } from './array/chunk.js';
|
|
95
94
|
export { concat } from './array/concat.js';
|
|
@@ -167,6 +166,7 @@ export { lowerCase } from './string/lowerCase.js';
|
|
|
167
166
|
export { upperCase } from './string/upperCase.js';
|
|
168
167
|
export { startsWith } from './string/startsWith.js';
|
|
169
168
|
export { endsWith } from './string/endsWith.js';
|
|
169
|
+
export { pad } from './string/pad.js';
|
|
170
170
|
export { padStart } from './string/padStart.js';
|
|
171
171
|
export { padEnd } from './string/padEnd.js';
|
|
172
172
|
export { repeat } from './string/repeat.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -1364,6 +1364,10 @@ function endsWith(str, target, position = str.length) {
|
|
|
1364
1364
|
return str.endsWith(target, position);
|
|
1365
1365
|
}
|
|
1366
1366
|
|
|
1367
|
+
function pad(str, length, chars = ' ') {
|
|
1368
|
+
return string_index.pad(toString(str), length, chars);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1367
1371
|
function padStart(str, length = 0, chars = ' ') {
|
|
1368
1372
|
return toString(str).padStart(length, chars);
|
|
1369
1373
|
}
|
|
@@ -1720,7 +1724,6 @@ exports.deburr = string_index.deburr;
|
|
|
1720
1724
|
exports.escape = string_index.escape;
|
|
1721
1725
|
exports.escapeRegExp = string_index.escapeRegExp;
|
|
1722
1726
|
exports.lowerFirst = string_index.lowerFirst;
|
|
1723
|
-
exports.pad = string_index.pad;
|
|
1724
1727
|
exports.pascalCase = string_index.pascalCase;
|
|
1725
1728
|
exports.unescape = string_index.unescape;
|
|
1726
1729
|
exports.upperFirst = string_index.upperFirst;
|
|
@@ -1790,6 +1793,7 @@ exports.mergeWith = mergeWith;
|
|
|
1790
1793
|
exports.min = min;
|
|
1791
1794
|
exports.omit = omit;
|
|
1792
1795
|
exports.orderBy = orderBy;
|
|
1796
|
+
exports.pad = pad;
|
|
1793
1797
|
exports.padEnd = padEnd;
|
|
1794
1798
|
exports.padStart = padStart;
|
|
1795
1799
|
exports.parseInt = parseInt;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -90,7 +90,6 @@ export { deburr } from '../string/deburr.mjs';
|
|
|
90
90
|
export { escape } from '../string/escape.mjs';
|
|
91
91
|
export { escapeRegExp } from '../string/escapeRegExp.mjs';
|
|
92
92
|
export { unescape } from '../string/unescape.mjs';
|
|
93
|
-
export { pad } from '../string/pad.mjs';
|
|
94
93
|
export { castArray } from './array/castArray.mjs';
|
|
95
94
|
export { chunk } from './array/chunk.mjs';
|
|
96
95
|
export { concat } from './array/concat.mjs';
|
|
@@ -167,6 +166,7 @@ export { lowerCase } from './string/lowerCase.mjs';
|
|
|
167
166
|
export { upperCase } from './string/upperCase.mjs';
|
|
168
167
|
export { startsWith } from './string/startsWith.mjs';
|
|
169
168
|
export { endsWith } from './string/endsWith.mjs';
|
|
169
|
+
export { pad } from './string/pad.mjs';
|
|
170
170
|
export { padStart } from './string/padStart.mjs';
|
|
171
171
|
export { padEnd } from './string/padEnd.mjs';
|
|
172
172
|
export { repeat } from './string/repeat.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
|
|
3
|
+
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} str - The string to pad.
|
|
6
|
+
* @param {number} [length] - The length of the resulting string once padded.
|
|
7
|
+
* @param {string} [chars] - The character(s) to use for padding.
|
|
8
|
+
* @returns {string} - The padded string, or the original string if padding is not required.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const result1 = pad('abc', 8); // result will be ' abc '
|
|
12
|
+
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
|
|
13
|
+
* const result3 = pad('abc', 3); // result will be 'abc'
|
|
14
|
+
* const result4 = pad('abc', 2); // result will be 'abc'
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
declare function pad(str: string, length: number, chars?: string): string;
|
|
18
|
+
|
|
19
|
+
export { pad };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
|
|
3
|
+
* If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} str - The string to pad.
|
|
6
|
+
* @param {number} [length] - The length of the resulting string once padded.
|
|
7
|
+
* @param {string} [chars] - The character(s) to use for padding.
|
|
8
|
+
* @returns {string} - The padded string, or the original string if padding is not required.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const result1 = pad('abc', 8); // result will be ' abc '
|
|
12
|
+
* const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
|
|
13
|
+
* const result3 = pad('abc', 3); // result will be 'abc'
|
|
14
|
+
* const result4 = pad('abc', 2); // result will be 'abc'
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
declare function pad(str: string, length: number, chars?: string): string;
|
|
18
|
+
|
|
19
|
+
export { pad };
|
package/dist/string/index.js
CHANGED
|
@@ -55,12 +55,7 @@ function startCase(str) {
|
|
|
55
55
|
if (result) {
|
|
56
56
|
result += ' ';
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
result += word;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
63
|
-
}
|
|
58
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
64
59
|
}
|
|
65
60
|
return result;
|
|
66
61
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const result1 = startCase('hello world'); // result will be 'Hello World'
|
|
10
|
-
* const result2 = startCase('HELLO WORLD'); // result will be '
|
|
10
|
+
* const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
|
|
11
11
|
* const result3 = startCase('hello-world'); // result will be 'Hello World'
|
|
12
12
|
* const result4 = startCase('hello_world'); // result will be 'Hello World'
|
|
13
13
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const result1 = startCase('hello world'); // result will be 'Hello World'
|
|
10
|
-
* const result2 = startCase('HELLO WORLD'); // result will be '
|
|
10
|
+
* const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
|
|
11
11
|
* const result3 = startCase('hello-world'); // result will be 'Hello World'
|
|
12
12
|
* const result4 = startCase('hello_world'); // result will be 'Hello World'
|
|
13
13
|
*/
|
|
@@ -8,12 +8,7 @@ function startCase(str) {
|
|
|
8
8
|
if (result) {
|
|
9
9
|
result += ' ';
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
result += word;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
16
|
-
}
|
|
11
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
17
12
|
}
|
|
18
13
|
return result;
|
|
19
14
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.20.0-dev.
|
|
4
|
+
"version": "1.20.0-dev.658+1e04c48d",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|