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

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.
@@ -45,6 +45,7 @@ export { tail } from '../array/tail.mjs';
45
45
  export { toFilled } from '../array/toFilled.mjs';
46
46
  export { last } from '../array/last.mjs';
47
47
  export { initial } from '../array/initial.mjs';
48
+ export { size } from '../array/size.mjs';
48
49
  export { AbortError } from '../error/AbortError.mjs';
49
50
  export { TimeoutError } from '../error/TimeoutError.mjs';
50
51
  export { before } from '../function/before.mjs';
@@ -92,6 +93,7 @@ export { kebabCase } from '../string/kebabCase.mjs';
92
93
  export { lowerCase } from '../string/lowerCase.mjs';
93
94
  export { startCase } from '../string/startCase.mjs';
94
95
  export { capitalize } from '../string/capitalize.mjs';
96
+ export { padStart } from '../string/padStart.mjs';
95
97
  export { chunk } from './array/chunk.mjs';
96
98
  export { concat } from './array/concat.mjs';
97
99
  export { difference } from './array/difference.mjs';
@@ -45,6 +45,7 @@ export { tail } from '../array/tail.js';
45
45
  export { toFilled } from '../array/toFilled.js';
46
46
  export { last } from '../array/last.js';
47
47
  export { initial } from '../array/initial.js';
48
+ export { size } from '../array/size.js';
48
49
  export { AbortError } from '../error/AbortError.js';
49
50
  export { TimeoutError } from '../error/TimeoutError.js';
50
51
  export { before } from '../function/before.js';
@@ -92,6 +93,7 @@ export { kebabCase } from '../string/kebabCase.js';
92
93
  export { lowerCase } from '../string/lowerCase.js';
93
94
  export { startCase } from '../string/startCase.js';
94
95
  export { capitalize } from '../string/capitalize.js';
96
+ export { padStart } from '../string/padStart.js';
95
97
  export { chunk } from './array/chunk.js';
96
98
  export { concat } from './array/concat.js';
97
99
  export { difference } from './array/difference.js';
@@ -3,14 +3,14 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const array_index = require('../array/index.js');
6
- const union = require('../_chunk/union-CdQeDK.js');
6
+ const isNil = require('../_chunk/isNil-IuJ4cv.js');
7
7
  const promise_index = require('../_chunk/index-CwRt_M.js');
8
8
  const function_index = require('../function/index.js');
9
9
  const math_index = require('../math/index.js');
10
10
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
11
11
  const object_index = require('../object/index.js');
12
12
  const predicate_index = require('../predicate/index.js');
13
- const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
13
+ const isPrimitive = require('../_chunk/isPrimitive-BBs6Fb.js');
14
14
  const string_index = require('../string/index.js');
15
15
 
16
16
  function chunk(arr, size = 1) {
@@ -258,7 +258,7 @@ function isArray(value) {
258
258
  }
259
259
 
260
260
  function isTypedArray(x) {
261
- return isTypedArray$1.isTypedArray(x);
261
+ return isPrimitive.isTypedArray(x);
262
262
  }
263
263
 
264
264
  function isArrayMatch(target, source) {
@@ -335,7 +335,7 @@ function isMatch(target, source) {
335
335
  }
336
336
  for (let i = 0; i < keys.length; i++) {
337
337
  const key = keys[i];
338
- if (!isTypedArray$1.isPrimitive(target) && !(key in target)) {
338
+ if (!isPrimitive.isPrimitive(target) && !(key in target)) {
339
339
  return false;
340
340
  }
341
341
  if (source[key] === undefined && target[key] !== undefined) {
@@ -425,6 +425,7 @@ exports.partition = array_index.partition;
425
425
  exports.sample = array_index.sample;
426
426
  exports.sampleSize = array_index.sampleSize;
427
427
  exports.shuffle = array_index.shuffle;
428
+ exports.size = array_index.size;
428
429
  exports.tail = array_index.tail;
429
430
  exports.take = array_index.take;
430
431
  exports.takeRight = array_index.takeRight;
@@ -444,8 +445,9 @@ exports.xorWith = array_index.xorWith;
444
445
  exports.zip = array_index.zip;
445
446
  exports.zipObject = array_index.zipObject;
446
447
  exports.zipWith = array_index.zipWith;
447
- exports.union = union.union;
448
- exports.uniq = union.uniq;
448
+ exports.isNil = isNil.isNil;
449
+ exports.union = isNil.union;
450
+ exports.uniq = isNil.uniq;
449
451
  exports.AbortError = promise_index.AbortError;
450
452
  exports.TimeoutError = promise_index.TimeoutError;
451
453
  exports.delay = promise_index.delay;
@@ -481,16 +483,16 @@ exports.isArrayLike = predicate_index.isArrayLike;
481
483
  exports.isEqual = predicate_index.isEqual;
482
484
  exports.isFunction = predicate_index.isFunction;
483
485
  exports.isLength = predicate_index.isLength;
484
- exports.isNil = predicate_index.isNil;
485
486
  exports.isNotNil = predicate_index.isNotNil;
486
487
  exports.isNull = predicate_index.isNull;
487
488
  exports.isObjectLike = predicate_index.isObjectLike;
488
489
  exports.isUndefined = predicate_index.isUndefined;
489
- exports.isPrimitive = isTypedArray$1.isPrimitive;
490
+ exports.isPrimitive = isPrimitive.isPrimitive;
490
491
  exports.camelCase = string_index.camelCase;
491
492
  exports.capitalize = string_index.capitalize;
492
493
  exports.kebabCase = string_index.kebabCase;
493
494
  exports.lowerCase = string_index.lowerCase;
495
+ exports.padStart = string_index.padStart;
494
496
  exports.snakeCase = string_index.snakeCase;
495
497
  exports.startCase = string_index.startCase;
496
498
  exports.chunk = chunk;
@@ -45,6 +45,7 @@ export { tail } from '../array/tail.mjs';
45
45
  export { toFilled } from '../array/toFilled.mjs';
46
46
  export { last } from '../array/last.mjs';
47
47
  export { initial } from '../array/initial.mjs';
48
+ export { size } from '../array/size.mjs';
48
49
  export { AbortError } from '../error/AbortError.mjs';
49
50
  export { TimeoutError } from '../error/TimeoutError.mjs';
50
51
  export { before } from '../function/before.mjs';
@@ -92,6 +93,7 @@ export { kebabCase } from '../string/kebabCase.mjs';
92
93
  export { lowerCase } from '../string/lowerCase.mjs';
93
94
  export { startCase } from '../string/startCase.mjs';
94
95
  export { capitalize } from '../string/capitalize.mjs';
96
+ export { padStart } from '../string/padStart.mjs';
95
97
  export { chunk } from './array/chunk.mjs';
96
98
  export { concat } from './array/concat.mjs';
97
99
  export { difference } from './array/difference.mjs';
package/dist/index.d.mts CHANGED
@@ -49,6 +49,7 @@ export { tail } from './array/tail.mjs';
49
49
  export { toFilled } from './array/toFilled.mjs';
50
50
  export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
+ export { size } from './array/size.mjs';
52
53
  export { AbortError } from './error/AbortError.mjs';
53
54
  export { TimeoutError } from './error/TimeoutError.mjs';
54
55
  export { before } from './function/before.mjs';
@@ -99,3 +100,4 @@ export { kebabCase } from './string/kebabCase.mjs';
99
100
  export { lowerCase } from './string/lowerCase.mjs';
100
101
  export { startCase } from './string/startCase.mjs';
101
102
  export { capitalize } from './string/capitalize.mjs';
103
+ export { padStart } from './string/padStart.mjs';
package/dist/index.d.ts CHANGED
@@ -49,6 +49,7 @@ export { tail } from './array/tail.js';
49
49
  export { toFilled } from './array/toFilled.js';
50
50
  export { last } from './array/last.js';
51
51
  export { initial } from './array/initial.js';
52
+ export { size } from './array/size.js';
52
53
  export { AbortError } from './error/AbortError.js';
53
54
  export { TimeoutError } from './error/TimeoutError.js';
54
55
  export { before } from './function/before.js';
@@ -99,3 +100,4 @@ export { kebabCase } from './string/kebabCase.js';
99
100
  export { lowerCase } from './string/lowerCase.js';
100
101
  export { startCase } from './string/startCase.js';
101
102
  export { capitalize } from './string/capitalize.js';
103
+ export { padStart } from './string/padStart.js';
package/dist/index.js CHANGED
@@ -3,14 +3,14 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  const array_index = require('./array/index.js');
6
- const union = require('./_chunk/union-CdQeDK.js');
6
+ const isNil = require('./_chunk/isNil-IuJ4cv.js');
7
7
  const promise_index = require('./_chunk/index-CwRt_M.js');
8
8
  const function_index = require('./function/index.js');
9
9
  const math_index = require('./math/index.js');
10
10
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
11
11
  const object_index = require('./object/index.js');
12
12
  const predicate_index = require('./predicate/index.js');
13
- const isTypedArray = require('./_chunk/isTypedArray-BBEkFl.js');
13
+ const isPrimitive = require('./_chunk/isPrimitive-BBs6Fb.js');
14
14
  const string_index = require('./string/index.js');
15
15
 
16
16
 
@@ -45,6 +45,7 @@ exports.partition = array_index.partition;
45
45
  exports.sample = array_index.sample;
46
46
  exports.sampleSize = array_index.sampleSize;
47
47
  exports.shuffle = array_index.shuffle;
48
+ exports.size = array_index.size;
48
49
  exports.tail = array_index.tail;
49
50
  exports.take = array_index.take;
50
51
  exports.takeRight = array_index.takeRight;
@@ -64,8 +65,9 @@ exports.xorWith = array_index.xorWith;
64
65
  exports.zip = array_index.zip;
65
66
  exports.zipObject = array_index.zipObject;
66
67
  exports.zipWith = array_index.zipWith;
67
- exports.union = union.union;
68
- exports.uniq = union.uniq;
68
+ exports.isNil = isNil.isNil;
69
+ exports.union = isNil.union;
70
+ exports.uniq = isNil.uniq;
69
71
  exports.AbortError = promise_index.AbortError;
70
72
  exports.TimeoutError = promise_index.TimeoutError;
71
73
  exports.delay = promise_index.delay;
@@ -102,17 +104,17 @@ exports.isArrayLike = predicate_index.isArrayLike;
102
104
  exports.isEqual = predicate_index.isEqual;
103
105
  exports.isFunction = predicate_index.isFunction;
104
106
  exports.isLength = predicate_index.isLength;
105
- exports.isNil = predicate_index.isNil;
106
107
  exports.isNotNil = predicate_index.isNotNil;
107
108
  exports.isNull = predicate_index.isNull;
108
109
  exports.isObjectLike = predicate_index.isObjectLike;
109
110
  exports.isUndefined = predicate_index.isUndefined;
110
- exports.isPlainObject = isTypedArray.isPlainObject;
111
- exports.isPrimitive = isTypedArray.isPrimitive;
112
- exports.isTypedArray = isTypedArray.isTypedArray;
111
+ exports.isPlainObject = isPrimitive.isPlainObject;
112
+ exports.isPrimitive = isPrimitive.isPrimitive;
113
+ exports.isTypedArray = isPrimitive.isTypedArray;
113
114
  exports.camelCase = string_index.camelCase;
114
115
  exports.capitalize = string_index.capitalize;
115
116
  exports.kebabCase = string_index.kebabCase;
116
117
  exports.lowerCase = string_index.lowerCase;
118
+ exports.padStart = string_index.padStart;
117
119
  exports.snakeCase = string_index.snakeCase;
118
120
  exports.startCase = string_index.startCase;
package/dist/index.mjs CHANGED
@@ -49,6 +49,7 @@ export { tail } from './array/tail.mjs';
49
49
  export { toFilled } from './array/toFilled.mjs';
50
50
  export { last } from './array/last.mjs';
51
51
  export { initial } from './array/initial.mjs';
52
+ export { size } from './array/size.mjs';
52
53
  export { AbortError } from './error/AbortError.mjs';
53
54
  export { TimeoutError } from './error/TimeoutError.mjs';
54
55
  export { before } from './function/before.mjs';
@@ -99,3 +100,4 @@ export { kebabCase } from './string/kebabCase.mjs';
99
100
  export { lowerCase } from './string/lowerCase.mjs';
100
101
  export { startCase } from './string/startCase.mjs';
101
102
  export { capitalize } from './string/capitalize.mjs';
103
+ export { padStart } from './string/padStart.mjs';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
5
+ const isPrimitive$1 = require('../_chunk/isPrimitive-BBs6Fb.js');
6
6
 
7
7
  function omit(obj, keys) {
8
8
  const result = { ...obj };
@@ -101,7 +101,7 @@ function flattenObjectImpl(object, prefix = '') {
101
101
  const key = keys[i];
102
102
  const value = object[key];
103
103
  const prefixedKey = prefix ? `${prefix}.${key}` : key;
104
- if (isTypedArray.isPlainObject(value) && Object.keys(value).length > 0) {
104
+ if (isPrimitive$1.isPlainObject(value) && Object.keys(value).length > 0) {
105
105
  Object.assign(result, flattenObjectImpl(value, prefixedKey));
106
106
  continue;
107
107
  }
@@ -142,7 +142,7 @@ function cloneDeep(obj) {
142
142
  return cloneDeepImpl(obj);
143
143
  }
144
144
  function cloneDeepImpl(obj, stack = new Map()) {
145
- if (isTypedArray.isPrimitive(obj)) {
145
+ if (isPrimitive$1.isPrimitive(obj)) {
146
146
  return obj;
147
147
  }
148
148
  if (stack.has(obj)) {
@@ -189,7 +189,7 @@ function cloneDeepImpl(obj, stack = new Map()) {
189
189
  if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
190
190
  return obj.subarray();
191
191
  }
192
- if (isTypedArray.isTypedArray(obj)) {
192
+ if (isPrimitive$1.isTypedArray(obj)) {
193
193
  const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);
194
194
  stack.set(obj, result);
195
195
  for (let i = 0; i < obj.length; i++) {
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const union = require('../_chunk/union-CdQeDK.js');
6
- const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
5
+ const isNil = require('../_chunk/isNil-IuJ4cv.js');
6
+ const isPrimitive = require('../_chunk/isPrimitive-BBs6Fb.js');
7
7
 
8
8
  function isEqual(a, b) {
9
9
  if (Object.is(a, b)) {
@@ -23,7 +23,7 @@ function isEqual(a, b) {
23
23
  if (aKeys.length !== bKeys.length) {
24
24
  return false;
25
25
  }
26
- if (union.union(aKeys, bKeys).length !== aKeys.length) {
26
+ if (isNil.union(aKeys, bKeys).length !== aKeys.length) {
27
27
  return false;
28
28
  }
29
29
  for (let i = 0; i < aKeys.length; i++) {
@@ -37,10 +37,6 @@ function isEqual(a, b) {
37
37
  return true;
38
38
  }
39
39
 
40
- function isNil(x) {
41
- return x == null;
42
- }
43
-
44
40
  function isNotNil(x) {
45
41
  return x !== null && x !== undefined;
46
42
  }
@@ -81,15 +77,15 @@ function isArguments(value) {
81
77
  return value !== null && typeof value === 'object' && getTag(value) === '[object Arguments]';
82
78
  }
83
79
 
84
- exports.isPlainObject = isTypedArray.isPlainObject;
85
- exports.isPrimitive = isTypedArray.isPrimitive;
86
- exports.isTypedArray = isTypedArray.isTypedArray;
80
+ exports.isNil = isNil.isNil;
81
+ exports.isPlainObject = isPrimitive.isPlainObject;
82
+ exports.isPrimitive = isPrimitive.isPrimitive;
83
+ exports.isTypedArray = isPrimitive.isTypedArray;
87
84
  exports.isArguments = isArguments;
88
85
  exports.isArrayLike = isArrayLike;
89
86
  exports.isEqual = isEqual;
90
87
  exports.isFunction = isFunction;
91
88
  exports.isLength = isLength;
92
- exports.isNil = isNil;
93
89
  exports.isNotNil = isNotNil;
94
90
  exports.isNull = isNull;
95
91
  exports.isObjectLike = isObjectLike;
@@ -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.361+fcc166a8",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -20,10 +20,6 @@ function isPlainObject(object) {
20
20
  return Object.getPrototypeOf(object) === proto;
21
21
  }
22
22
 
23
- function isPrimitive(value) {
24
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
25
- }
26
-
27
23
  function isTypedArray(x) {
28
24
  return (x instanceof Uint8Array ||
29
25
  x instanceof Uint8ClampedArray ||
@@ -38,6 +34,10 @@ function isTypedArray(x) {
38
34
  x instanceof Float64Array);
39
35
  }
40
36
 
37
+ function isPrimitive(value) {
38
+ return value == null || (typeof value !== 'object' && typeof value !== 'function');
39
+ }
40
+
41
41
  exports.isPlainObject = isPlainObject;
42
42
  exports.isPrimitive = isPrimitive;
43
43
  exports.isTypedArray = isTypedArray;