es-toolkit 1.13.1-dev.359 → 1.13.1-dev.360

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.
@@ -92,6 +92,7 @@ export { kebabCase } from '../string/kebabCase.mjs';
92
92
  export { lowerCase } from '../string/lowerCase.mjs';
93
93
  export { startCase } from '../string/startCase.mjs';
94
94
  export { capitalize } from '../string/capitalize.mjs';
95
+ export { padStart } from '../string/padStart.mjs';
95
96
  export { chunk } from './array/chunk.mjs';
96
97
  export { concat } from './array/concat.mjs';
97
98
  export { difference } from './array/difference.mjs';
@@ -92,6 +92,7 @@ export { kebabCase } from '../string/kebabCase.js';
92
92
  export { lowerCase } from '../string/lowerCase.js';
93
93
  export { startCase } from '../string/startCase.js';
94
94
  export { capitalize } from '../string/capitalize.js';
95
+ export { padStart } from '../string/padStart.js';
95
96
  export { chunk } from './array/chunk.js';
96
97
  export { concat } from './array/concat.js';
97
98
  export { difference } from './array/difference.js';
@@ -491,6 +491,7 @@ exports.camelCase = string_index.camelCase;
491
491
  exports.capitalize = string_index.capitalize;
492
492
  exports.kebabCase = string_index.kebabCase;
493
493
  exports.lowerCase = string_index.lowerCase;
494
+ exports.padStart = string_index.padStart;
494
495
  exports.snakeCase = string_index.snakeCase;
495
496
  exports.startCase = string_index.startCase;
496
497
  exports.chunk = chunk;
@@ -92,6 +92,7 @@ export { kebabCase } from '../string/kebabCase.mjs';
92
92
  export { lowerCase } from '../string/lowerCase.mjs';
93
93
  export { startCase } from '../string/startCase.mjs';
94
94
  export { capitalize } from '../string/capitalize.mjs';
95
+ export { padStart } from '../string/padStart.mjs';
95
96
  export { chunk } from './array/chunk.mjs';
96
97
  export { concat } from './array/concat.mjs';
97
98
  export { difference } from './array/difference.mjs';
package/dist/index.d.mts CHANGED
@@ -99,3 +99,4 @@ export { kebabCase } from './string/kebabCase.mjs';
99
99
  export { lowerCase } from './string/lowerCase.mjs';
100
100
  export { startCase } from './string/startCase.mjs';
101
101
  export { capitalize } from './string/capitalize.mjs';
102
+ export { padStart } from './string/padStart.mjs';
package/dist/index.d.ts CHANGED
@@ -99,3 +99,4 @@ export { kebabCase } from './string/kebabCase.js';
99
99
  export { lowerCase } from './string/lowerCase.js';
100
100
  export { startCase } from './string/startCase.js';
101
101
  export { capitalize } from './string/capitalize.js';
102
+ export { padStart } from './string/padStart.js';
package/dist/index.js CHANGED
@@ -114,5 +114,6 @@ exports.camelCase = string_index.camelCase;
114
114
  exports.capitalize = string_index.capitalize;
115
115
  exports.kebabCase = string_index.kebabCase;
116
116
  exports.lowerCase = string_index.lowerCase;
117
+ exports.padStart = string_index.padStart;
117
118
  exports.snakeCase = string_index.snakeCase;
118
119
  exports.startCase = string_index.startCase;
package/dist/index.mjs CHANGED
@@ -99,3 +99,4 @@ export { kebabCase } from './string/kebabCase.mjs';
99
99
  export { lowerCase } from './string/lowerCase.mjs';
100
100
  export { startCase } from './string/startCase.mjs';
101
101
  export { capitalize } from './string/capitalize.mjs';
102
+ export { padStart } from './string/padStart.mjs';
@@ -4,3 +4,4 @@ export { kebabCase } from './kebabCase.mjs';
4
4
  export { lowerCase } from './lowerCase.mjs';
5
5
  export { startCase } from './startCase.mjs';
6
6
  export { capitalize } from './capitalize.mjs';
7
+ export { padStart } from './padStart.mjs';
@@ -4,3 +4,4 @@ export { kebabCase } from './kebabCase.js';
4
4
  export { lowerCase } from './lowerCase.js';
5
5
  export { startCase } from './startCase.js';
6
6
  export { capitalize } from './capitalize.js';
7
+ export { padStart } from './padStart.js';
@@ -52,9 +52,17 @@ function startCase(str) {
52
52
  return result;
53
53
  }
54
54
 
55
+ const padStart = (str, length = 0, chars = ' ') => {
56
+ if (Number.isSafeInteger(length) && length > str.length && chars.length > 0) {
57
+ return str.padStart(length, chars);
58
+ }
59
+ return str;
60
+ };
61
+
55
62
  exports.camelCase = camelCase;
56
63
  exports.capitalize = capitalize;
57
64
  exports.kebabCase = kebabCase;
58
65
  exports.lowerCase = lowerCase;
66
+ exports.padStart = padStart;
59
67
  exports.snakeCase = snakeCase;
60
68
  exports.startCase = startCase;
@@ -4,3 +4,4 @@ export { kebabCase } from './kebabCase.mjs';
4
4
  export { lowerCase } from './lowerCase.mjs';
5
5
  export { startCase } from './startCase.mjs';
6
6
  export { capitalize } from './capitalize.mjs';
7
+ export { padStart } from './padStart.mjs';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pads the start of a string with a given character until it reaches the specified 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,
4
+ * the original string is returned unchanged.
5
+ *
6
+ * @template T - The type of the input string.
7
+ * @param {T} str - The string to pad.
8
+ * @param {number} [length=0] - The length of the resulting string once padded. Default is 0.
9
+ * @param {string} [chars=' '] - The character(s) to use for padding. Default is a single space.
10
+ * @returns {string} - The padded string, or the original string if padding is not required.
11
+ *
12
+ * @example
13
+ * const result1 = padStart('abc', 6); // result will be ' abc'
14
+ * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
15
+ * const result3 = padStart('abc', 3); // result will be 'abc'
16
+ * const result4 = padStart('abc', 2); // result will be 'abc'
17
+ */
18
+ declare const padStart: <T extends string>(str: T, length?: number, chars?: string) => string;
19
+
20
+ export { padStart };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pads the start of a string with a given character until it reaches the specified 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,
4
+ * the original string is returned unchanged.
5
+ *
6
+ * @template T - The type of the input string.
7
+ * @param {T} str - The string to pad.
8
+ * @param {number} [length=0] - The length of the resulting string once padded. Default is 0.
9
+ * @param {string} [chars=' '] - The character(s) to use for padding. Default is a single space.
10
+ * @returns {string} - The padded string, or the original string if padding is not required.
11
+ *
12
+ * @example
13
+ * const result1 = padStart('abc', 6); // result will be ' abc'
14
+ * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
15
+ * const result3 = padStart('abc', 3); // result will be 'abc'
16
+ * const result4 = padStart('abc', 2); // result will be 'abc'
17
+ */
18
+ declare const padStart: <T extends string>(str: T, length?: number, chars?: string) => string;
19
+
20
+ export { padStart };
@@ -0,0 +1,8 @@
1
+ const padStart = (str, length = 0, chars = ' ') => {
2
+ if (Number.isSafeInteger(length) && length > str.length && chars.length > 0) {
3
+ return str.padStart(length, chars);
4
+ }
5
+ return str;
6
+ };
7
+
8
+ export { padStart };
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.13.1-dev.359+2d1c4063",
4
+ "version": "1.13.1-dev.360+8249ed25",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {