es-toolkit 1.27.0 → 1.28.0-dev.908

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/_chunk/{isWeakSet-D8h8bS.js → isWeakSet-CvIdTA.js} +5 -0
  3. package/dist/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
  4. package/dist/array/differenceBy.d.mts +10 -3
  5. package/dist/array/differenceBy.d.ts +10 -3
  6. package/dist/array/differenceWith.d.mts +11 -4
  7. package/dist/array/differenceWith.d.ts +11 -4
  8. package/dist/array/flatMap.d.mts +1 -1
  9. package/dist/array/flatMap.d.ts +1 -1
  10. package/dist/array/intersectionBy.d.mts +16 -5
  11. package/dist/array/intersectionBy.d.ts +16 -5
  12. package/dist/array/intersectionWith.d.mts +16 -4
  13. package/dist/array/intersectionWith.d.ts +16 -4
  14. package/dist/browser.global.js +1 -1
  15. package/dist/browser.global.js.map +1 -1
  16. package/dist/compat/array/dropRightWhile.d.mts +2 -2
  17. package/dist/compat/array/dropRightWhile.d.ts +2 -2
  18. package/dist/compat/array/dropRightWhile.mjs +2 -0
  19. package/dist/compat/array/dropWhile.d.mts +2 -2
  20. package/dist/compat/array/dropWhile.d.ts +2 -2
  21. package/dist/compat/array/dropWhile.mjs +2 -0
  22. package/dist/compat/array/every.d.mts +6 -6
  23. package/dist/compat/array/every.d.ts +6 -6
  24. package/dist/compat/array/every.mjs +2 -0
  25. package/dist/compat/array/filter.d.mts +4 -4
  26. package/dist/compat/array/filter.d.ts +4 -4
  27. package/dist/compat/array/filter.mjs +2 -0
  28. package/dist/compat/array/find.d.mts +6 -6
  29. package/dist/compat/array/find.d.ts +6 -6
  30. package/dist/compat/array/find.mjs +2 -0
  31. package/dist/compat/array/findIndex.d.mts +3 -3
  32. package/dist/compat/array/findIndex.d.ts +3 -3
  33. package/dist/compat/array/findIndex.mjs +2 -0
  34. package/dist/compat/array/findLastIndex.d.mts +3 -3
  35. package/dist/compat/array/findLastIndex.d.ts +3 -3
  36. package/dist/compat/array/findLastIndex.mjs +2 -0
  37. package/dist/compat/array/some.d.mts +5 -5
  38. package/dist/compat/array/some.d.ts +5 -5
  39. package/dist/compat/array/some.mjs +2 -0
  40. package/dist/compat/array/uniqBy.d.mts +34 -13
  41. package/dist/compat/array/uniqBy.d.ts +34 -13
  42. package/dist/compat/array/uniqBy.mjs +3 -16
  43. package/dist/compat/function/debounce.d.mts +7 -5
  44. package/dist/compat/function/debounce.d.ts +7 -5
  45. package/dist/compat/function/throttle.d.mts +3 -4
  46. package/dist/compat/function/throttle.d.ts +3 -4
  47. package/dist/compat/function/throttle.mjs +6 -1
  48. package/dist/compat/index.d.mts +12 -2
  49. package/dist/compat/index.d.ts +12 -2
  50. package/dist/compat/index.js +179 -48
  51. package/dist/compat/index.mjs +10 -1
  52. package/dist/compat/math/add.d.mts +18 -0
  53. package/dist/compat/math/add.d.ts +18 -0
  54. package/dist/compat/math/add.mjs +5 -0
  55. package/dist/compat/object/assignIn.d.mts +103 -0
  56. package/dist/compat/object/assignIn.d.ts +103 -0
  57. package/dist/compat/object/assignIn.mjs +20 -0
  58. package/dist/compat/object/keysIn.d.mts +26 -0
  59. package/dist/compat/object/keysIn.d.ts +26 -0
  60. package/dist/compat/object/keysIn.mjs +53 -0
  61. package/dist/compat/predicate/isElement.d.mts +13 -0
  62. package/dist/compat/predicate/isElement.d.ts +13 -0
  63. package/dist/compat/predicate/isElement.mjs +8 -0
  64. package/dist/compat/string/toUpper.d.mts +20 -0
  65. package/dist/compat/string/toUpper.d.ts +20 -0
  66. package/dist/compat/string/toUpper.mjs +7 -0
  67. package/dist/compat/string/trim.mjs +1 -1
  68. package/dist/compat/string/trimEnd.mjs +1 -1
  69. package/dist/compat/string/trimStart.mjs +1 -1
  70. package/dist/compat/string/words.d.mts +15 -0
  71. package/dist/compat/string/words.d.ts +15 -0
  72. package/dist/compat/string/words.mjs +10 -0
  73. package/dist/compat/util/gt.d.mts +15 -0
  74. package/dist/compat/util/gt.d.ts +15 -0
  75. package/dist/compat/util/gt.mjs +10 -0
  76. package/dist/compat/util/gte.d.mts +15 -0
  77. package/dist/compat/util/gte.d.ts +15 -0
  78. package/dist/compat/util/gte.mjs +10 -0
  79. package/dist/compat/util/iteratee.d.mts +1 -1
  80. package/dist/compat/util/iteratee.d.ts +1 -1
  81. package/dist/compat/util/toArray.d.mts +15 -0
  82. package/dist/compat/util/toArray.d.ts +15 -0
  83. package/dist/compat/util/toArray.mjs +20 -0
  84. package/dist/function/debounce.d.mts +24 -22
  85. package/dist/function/debounce.d.ts +24 -22
  86. package/dist/function/index.d.mts +2 -2
  87. package/dist/function/index.d.ts +2 -2
  88. package/dist/function/partial.d.mts +533 -15
  89. package/dist/function/partial.d.ts +533 -15
  90. package/dist/function/partialRight.d.mts +610 -15
  91. package/dist/function/partialRight.d.ts +610 -15
  92. package/dist/function/throttle.d.mts +7 -5
  93. package/dist/function/throttle.d.ts +7 -5
  94. package/dist/index.d.mts +3 -2
  95. package/dist/index.d.ts +3 -2
  96. package/dist/index.js +3 -2
  97. package/dist/index.mjs +1 -0
  98. package/dist/predicate/index.d.mts +1 -0
  99. package/dist/predicate/index.d.ts +1 -0
  100. package/dist/predicate/index.js +2 -1
  101. package/dist/predicate/index.mjs +1 -0
  102. package/dist/predicate/isBuffer.d.mts +21 -0
  103. package/dist/predicate/isBuffer.d.ts +21 -0
  104. package/dist/predicate/isBuffer.mjs +5 -0
  105. package/dist/string/index.js +1 -1
  106. package/package.json +1 -1
@@ -12,6 +12,11 @@ interface ThrottleOptions {
12
12
  */
13
13
  edges?: Array<'leading' | 'trailing'>;
14
14
  }
15
+ interface ThrottledFunction<F extends (...args: any[]) => void> {
16
+ (...args: Parameters<F>): void;
17
+ cancel: () => void;
18
+ flush: () => void;
19
+ }
15
20
  /**
16
21
  * Creates a throttled function that only invokes the provided function at most once
17
22
  * per every `throttleMs` milliseconds. Subsequent calls to the throttled function
@@ -38,9 +43,6 @@ interface ThrottleOptions {
38
43
  * throttledFunction(); // Will log 'Function executed'
39
44
  * }, 1000);
40
45
  */
41
- declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ((...args: Parameters<F>) => void) & {
42
- cancel: () => void;
43
- flush: () => void;
44
- };
46
+ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
45
47
 
46
- export { throttle };
48
+ export { type ThrottledFunction, throttle };
package/dist/index.d.mts CHANGED
@@ -62,7 +62,7 @@ export { ary } from './function/ary.mjs';
62
62
  export { before } from './function/before.mjs';
63
63
  export { curry } from './function/curry.mjs';
64
64
  export { curryRight } from './function/curryRight.mjs';
65
- export { debounce } from './function/debounce.mjs';
65
+ export { DebouncedFunction, debounce } from './function/debounce.mjs';
66
66
  export { flow } from './function/flow.mjs';
67
67
  export { flowRight } from './function/flowRight.mjs';
68
68
  export { identity } from './function/identity.mjs';
@@ -74,7 +74,7 @@ export { partial } from './function/partial.mjs';
74
74
  export { partialRight } from './function/partialRight.mjs';
75
75
  export { rest } from './function/rest.mjs';
76
76
  export { spread } from './function/spread.mjs';
77
- export { throttle } from './function/throttle.mjs';
77
+ export { ThrottledFunction, throttle } from './function/throttle.mjs';
78
78
  export { unary } from './function/unary.mjs';
79
79
  export { clamp } from './math/clamp.mjs';
80
80
  export { inRange } from './math/inRange.mjs';
@@ -106,6 +106,7 @@ export { toMerged } from './object/toMerged.mjs';
106
106
  export { isArrayBuffer } from './predicate/isArrayBuffer.mjs';
107
107
  export { isBlob } from './predicate/isBlob.mjs';
108
108
  export { isBoolean } from './predicate/isBoolean.mjs';
109
+ export { isBuffer } from './predicate/isBuffer.mjs';
109
110
  export { isDate } from './predicate/isDate.mjs';
110
111
  export { isEqual } from './predicate/isEqual.mjs';
111
112
  export { isEqualWith } from './predicate/isEqualWith.mjs';
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ export { ary } from './function/ary.js';
62
62
  export { before } from './function/before.js';
63
63
  export { curry } from './function/curry.js';
64
64
  export { curryRight } from './function/curryRight.js';
65
- export { debounce } from './function/debounce.js';
65
+ export { DebouncedFunction, debounce } from './function/debounce.js';
66
66
  export { flow } from './function/flow.js';
67
67
  export { flowRight } from './function/flowRight.js';
68
68
  export { identity } from './function/identity.js';
@@ -74,7 +74,7 @@ export { partial } from './function/partial.js';
74
74
  export { partialRight } from './function/partialRight.js';
75
75
  export { rest } from './function/rest.js';
76
76
  export { spread } from './function/spread.js';
77
- export { throttle } from './function/throttle.js';
77
+ export { ThrottledFunction, throttle } from './function/throttle.js';
78
78
  export { unary } from './function/unary.js';
79
79
  export { clamp } from './math/clamp.js';
80
80
  export { inRange } from './math/inRange.js';
@@ -106,6 +106,7 @@ export { toMerged } from './object/toMerged.js';
106
106
  export { isArrayBuffer } from './predicate/isArrayBuffer.js';
107
107
  export { isBlob } from './predicate/isBlob.js';
108
108
  export { isBoolean } from './predicate/isBoolean.js';
109
+ export { isBuffer } from './predicate/isBuffer.js';
109
110
  export { isDate } from './predicate/isDate.js';
110
111
  export { isEqual } from './predicate/isEqual.js';
111
112
  export { isEqualWith } from './predicate/isEqualWith.js';
package/dist/index.js CHANGED
@@ -13,10 +13,10 @@ const randomInt = require('./_chunk/randomInt-CF7bZK.js');
13
13
  const math_index = require('./math/index.js');
14
14
  const toMerged = require('./_chunk/toMerged-CPY8Ug.js');
15
15
  const object_index = require('./object/index.js');
16
- const isWeakSet = require('./_chunk/isWeakSet-D8h8bS.js');
16
+ const isWeakSet = require('./_chunk/isWeakSet-CvIdTA.js');
17
17
  const predicate_index = require('./predicate/index.js');
18
18
  const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
19
- const upperFirst = require('./_chunk/upperFirst-DK_rTF.js');
19
+ const upperFirst = require('./_chunk/upperFirst-CorAVn.js');
20
20
  const string_index = require('./string/index.js');
21
21
  const util_index = require('./util/index.js');
22
22
 
@@ -132,6 +132,7 @@ exports.omit = object_index.omit;
132
132
  exports.pick = object_index.pick;
133
133
  exports.isArrayBuffer = isWeakSet.isArrayBuffer;
134
134
  exports.isBlob = isWeakSet.isBlob;
135
+ exports.isBuffer = isWeakSet.isBuffer;
135
136
  exports.isDate = isWeakSet.isDate;
136
137
  exports.isEqual = isWeakSet.isEqual;
137
138
  exports.isEqualWith = isWeakSet.isEqualWith;
package/dist/index.mjs CHANGED
@@ -106,6 +106,7 @@ export { toMerged } from './object/toMerged.mjs';
106
106
  export { isArrayBuffer } from './predicate/isArrayBuffer.mjs';
107
107
  export { isBlob } from './predicate/isBlob.mjs';
108
108
  export { isBoolean } from './predicate/isBoolean.mjs';
109
+ export { isBuffer } from './predicate/isBuffer.mjs';
109
110
  export { isDate } from './predicate/isDate.mjs';
110
111
  export { isEqual } from './predicate/isEqual.mjs';
111
112
  export { isEqualWith } from './predicate/isEqualWith.mjs';
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.mjs';
2
2
  export { isBlob } from './isBlob.mjs';
3
3
  export { isBoolean } from './isBoolean.mjs';
4
+ export { isBuffer } from './isBuffer.mjs';
4
5
  export { isDate } from './isDate.mjs';
5
6
  export { isEqual } from './isEqual.mjs';
6
7
  export { isEqualWith } from './isEqualWith.mjs';
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.js';
2
2
  export { isBlob } from './isBlob.js';
3
3
  export { isBoolean } from './isBoolean.js';
4
+ export { isBuffer } from './isBuffer.js';
4
5
  export { isDate } from './isDate.js';
5
6
  export { isEqual } from './isEqual.js';
6
7
  export { isEqualWith } from './isEqualWith.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-D8h8bS.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-CvIdTA.js');
6
6
  const isPlainObject = require('../_chunk/isPlainObject-octpoD.js');
7
7
 
8
8
  function isBoolean(x) {
@@ -23,6 +23,7 @@ function isSymbol(value) {
23
23
 
24
24
  exports.isArrayBuffer = isWeakSet.isArrayBuffer;
25
25
  exports.isBlob = isWeakSet.isBlob;
26
+ exports.isBuffer = isWeakSet.isBuffer;
26
27
  exports.isDate = isWeakSet.isDate;
27
28
  exports.isEqual = isWeakSet.isEqual;
28
29
  exports.isEqualWith = isWeakSet.isEqualWith;
@@ -1,6 +1,7 @@
1
1
  export { isArrayBuffer } from './isArrayBuffer.mjs';
2
2
  export { isBlob } from './isBlob.mjs';
3
3
  export { isBoolean } from './isBoolean.mjs';
4
+ export { isBuffer } from './isBuffer.mjs';
4
5
  export { isDate } from './isDate.mjs';
5
6
  export { isEqual } from './isEqual.mjs';
6
7
  export { isEqualWith } from './isEqualWith.mjs';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Checks if the given value is a Buffer instance.
3
+ *
4
+ * This function tests whether the provided value is an instance of Buffer.
5
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
8
+ *
9
+ * @param {unknown} x - The value to check if it is a Buffer.
10
+ * @returns {boolean} Returns `true` if `x` is a Buffer, else `false`.
11
+ *
12
+ * @example
13
+ * const buffer = Buffer.from("test");
14
+ * console.log(isBuffer(buffer)); // true
15
+ *
16
+ * const notBuffer = "not a buffer";
17
+ * console.log(isBuffer(notBuffer)); // false
18
+ */
19
+ declare function isBuffer(x: unknown): boolean;
20
+
21
+ export { isBuffer };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Checks if the given value is a Buffer instance.
3
+ *
4
+ * This function tests whether the provided value is an instance of Buffer.
5
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
8
+ *
9
+ * @param {unknown} x - The value to check if it is a Buffer.
10
+ * @returns {boolean} Returns `true` if `x` is a Buffer, else `false`.
11
+ *
12
+ * @example
13
+ * const buffer = Buffer.from("test");
14
+ * console.log(isBuffer(buffer)); // true
15
+ *
16
+ * const notBuffer = "not a buffer";
17
+ * console.log(isBuffer(notBuffer)); // false
18
+ */
19
+ declare function isBuffer(x: unknown): boolean;
20
+
21
+ export { isBuffer };
@@ -0,0 +1,5 @@
1
+ function isBuffer(x) {
2
+ return typeof Buffer !== 'undefined' && Buffer.isBuffer(x);
3
+ }
4
+
5
+ export { isBuffer };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const upperFirst = require('../_chunk/upperFirst-DK_rTF.js');
5
+ const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
6
6
 
7
7
  function startCase(str) {
8
8
  const words = upperFirst.words(str.trim());
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.27.0",
4
+ "version": "1.28.0-dev.908+e1c05f28",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {