es-toolkit 1.32.0 → 1.33.0-dev.1025

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 (66) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/_chunk/{isWeakSet-DoHqUM.js → isWeakSet-TIM260.js} +14 -0
  3. package/dist/_chunk/{toMerged-BQTfB8.js → toMerged-CwnQF6.js} +0 -14
  4. package/dist/_chunk/{upperFirst-CorAVn.js → upperFirst-nA5L7X.js} +5 -0
  5. package/dist/browser.global.js +1 -1
  6. package/dist/browser.global.js.map +1 -1
  7. package/dist/compat/array/find.mjs +12 -32
  8. package/dist/compat/array/findLast.d.mts +130 -0
  9. package/dist/compat/array/findLast.d.ts +130 -0
  10. package/dist/compat/array/findLast.mjs +32 -0
  11. package/dist/compat/array/intersectionWith.d.mts +96 -0
  12. package/dist/compat/array/intersectionWith.d.ts +96 -0
  13. package/dist/compat/array/intersectionWith.mjs +43 -0
  14. package/dist/compat/array/pullAllBy.d.mts +64 -0
  15. package/dist/compat/array/pullAllBy.d.ts +64 -0
  16. package/dist/compat/array/pullAllBy.mjs +22 -0
  17. package/dist/compat/array/reduce.d.mts +109 -0
  18. package/dist/compat/array/reduce.d.ts +109 -0
  19. package/dist/compat/array/reduce.mjs +33 -0
  20. package/dist/compat/array/reduceRight.d.mts +109 -0
  21. package/dist/compat/array/reduceRight.d.ts +109 -0
  22. package/dist/compat/array/reduceRight.mjs +39 -0
  23. package/dist/compat/index.d.mts +12 -3
  24. package/dist/compat/index.d.ts +12 -3
  25. package/dist/compat/index.js +264 -63
  26. package/dist/compat/index.mjs +12 -3
  27. package/dist/compat/math/divide.d.mts +18 -0
  28. package/dist/compat/math/divide.d.ts +18 -0
  29. package/dist/compat/math/divide.mjs +23 -0
  30. package/dist/compat/math/maxBy.d.mts +31 -0
  31. package/dist/compat/math/maxBy.d.ts +31 -0
  32. package/dist/compat/math/maxBy.mjs +11 -0
  33. package/dist/compat/math/multiply.mjs +4 -3
  34. package/dist/compat/math/sumBy.mjs +8 -3
  35. package/dist/compat/object/assignIn.mjs +1 -1
  36. package/dist/compat/object/pickBy.d.mts +22 -0
  37. package/dist/compat/object/pickBy.d.ts +22 -0
  38. package/dist/compat/object/pickBy.mjs +23 -0
  39. package/dist/compat/object/values.d.mts +32 -0
  40. package/dist/compat/object/values.d.ts +32 -0
  41. package/dist/compat/object/values.mjs +5 -0
  42. package/dist/compat/object/valuesIn.d.mts +63 -0
  43. package/dist/compat/object/valuesIn.d.ts +63 -0
  44. package/dist/compat/object/valuesIn.mjs +13 -0
  45. package/dist/index.d.mts +2 -0
  46. package/dist/index.d.ts +2 -0
  47. package/dist/index.js +6 -4
  48. package/dist/index.mjs +2 -0
  49. package/dist/object/flattenObject.d.mts +1 -1
  50. package/dist/object/flattenObject.d.ts +1 -1
  51. package/dist/object/index.js +15 -2
  52. package/dist/predicate/index.d.mts +1 -0
  53. package/dist/predicate/index.d.ts +1 -0
  54. package/dist/predicate/index.js +2 -1
  55. package/dist/predicate/index.mjs +1 -0
  56. package/dist/predicate/isJSON.d.mts +31 -0
  57. package/dist/predicate/isJSON.d.ts +31 -0
  58. package/dist/predicate/isJSON.mjs +14 -0
  59. package/dist/string/index.d.mts +1 -0
  60. package/dist/string/index.d.ts +1 -0
  61. package/dist/string/index.js +2 -1
  62. package/dist/string/index.mjs +1 -0
  63. package/dist/string/reverseString.d.mts +16 -0
  64. package/dist/string/reverseString.d.ts +16 -0
  65. package/dist/string/reverseString.mjs +5 -0
  66. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -119,6 +119,7 @@ export { isEqualWith } from './predicate/isEqualWith.mjs';
119
119
  export { isError } from './predicate/isError.mjs';
120
120
  export { isFile } from './predicate/isFile.mjs';
121
121
  export { isFunction } from './predicate/isFunction.mjs';
122
+ export { isJSON } from './predicate/isJSON.mjs';
122
123
  export { isJSONArray, isJSONObject, isJSONValue } from './predicate/isJSONValue.mjs';
123
124
  export { isLength } from './predicate/isLength.mjs';
124
125
  export { isMap } from './predicate/isMap.mjs';
@@ -152,6 +153,7 @@ export { lowerCase } from './string/lowerCase.mjs';
152
153
  export { lowerFirst } from './string/lowerFirst.mjs';
153
154
  export { pad } from './string/pad.mjs';
154
155
  export { pascalCase } from './string/pascalCase.mjs';
156
+ export { reverseString } from './string/reverseString.mjs';
155
157
  export { snakeCase } from './string/snakeCase.mjs';
156
158
  export { startCase } from './string/startCase.mjs';
157
159
  export { trim } from './string/trim.mjs';
@@ -1,7 +1,7 @@
1
1
  interface FlattenObjectOptions {
2
2
  /**
3
3
  * The delimiter to use between nested keys.
4
- * @default '.''
4
+ * @default '.'
5
5
  */
6
6
  delimiter?: string;
7
7
  }
@@ -1,7 +1,7 @@
1
1
  interface FlattenObjectOptions {
2
2
  /**
3
3
  * The delimiter to use between nested keys.
4
- * @default '.''
4
+ * @default '.'
5
5
  */
6
6
  delimiter?: string;
7
7
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const toMerged = require('../_chunk/toMerged-BQTfB8.js');
5
+ const toMerged = require('../_chunk/toMerged-CwnQF6.js');
6
6
 
7
7
  function mergeWith(target, source, merge) {
8
8
  const sourceKeys = Object.keys(source);
@@ -47,6 +47,19 @@ function pick(obj, keys) {
47
47
  return result;
48
48
  }
49
49
 
50
+ function pickBy(obj, shouldPick) {
51
+ const result = {};
52
+ const keys = Object.keys(obj);
53
+ for (let i = 0; i < keys.length; i++) {
54
+ const key = keys[i];
55
+ const value = obj[key];
56
+ if (shouldPick(value, key)) {
57
+ result[key] = value;
58
+ }
59
+ }
60
+ return result;
61
+ }
62
+
50
63
  exports.clone = toMerged.clone;
51
64
  exports.cloneDeep = toMerged.cloneDeep;
52
65
  exports.cloneDeepWith = toMerged.cloneDeepWith;
@@ -57,8 +70,8 @@ exports.mapKeys = toMerged.mapKeys;
57
70
  exports.mapValues = toMerged.mapValues;
58
71
  exports.merge = toMerged.merge;
59
72
  exports.omitBy = toMerged.omitBy;
60
- exports.pickBy = toMerged.pickBy;
61
73
  exports.toMerged = toMerged.toMerged;
62
74
  exports.mergeWith = mergeWith;
63
75
  exports.omit = omit;
64
76
  exports.pick = pick;
77
+ exports.pickBy = pickBy;
@@ -8,6 +8,7 @@ export { isEqualWith } from './isEqualWith.mjs';
8
8
  export { isError } from './isError.mjs';
9
9
  export { isFile } from './isFile.mjs';
10
10
  export { isFunction } from './isFunction.mjs';
11
+ export { isJSON } from './isJSON.mjs';
11
12
  export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.mjs';
12
13
  export { isLength } from './isLength.mjs';
13
14
  export { isMap } from './isMap.mjs';
@@ -8,6 +8,7 @@ export { isEqualWith } from './isEqualWith.js';
8
8
  export { isError } from './isError.js';
9
9
  export { isFile } from './isFile.js';
10
10
  export { isFunction } from './isFunction.js';
11
+ export { isJSON } from './isJSON.js';
11
12
  export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.js';
12
13
  export { isLength } from './isLength.js';
13
14
  export { isMap } from './isMap.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-DoHqUM.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-TIM260.js');
6
6
  const isPlainObject = require('../_chunk/isPlainObject-Xaozpc.js');
7
7
 
8
8
  function isBoolean(x) {
@@ -25,6 +25,7 @@ exports.isEqual = isWeakSet.isEqual;
25
25
  exports.isEqualWith = isWeakSet.isEqualWith;
26
26
  exports.isFile = isWeakSet.isFile;
27
27
  exports.isFunction = isWeakSet.isFunction;
28
+ exports.isJSON = isWeakSet.isJSON;
28
29
  exports.isJSONArray = isWeakSet.isJSONArray;
29
30
  exports.isJSONObject = isWeakSet.isJSONObject;
30
31
  exports.isJSONValue = isWeakSet.isJSONValue;
@@ -8,6 +8,7 @@ export { isEqualWith } from './isEqualWith.mjs';
8
8
  export { isError } from './isError.mjs';
9
9
  export { isFile } from './isFile.mjs';
10
10
  export { isFunction } from './isFunction.mjs';
11
+ export { isJSON } from './isJSON.mjs';
11
12
  export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.mjs';
12
13
  export { isLength } from './isLength.mjs';
13
14
  export { isMap } from './isMap.mjs';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON string.
3
+ *
4
+ * A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON
5
+ * specifications, valid JSON can represent:
6
+ * - Objects (with string keys and valid JSON values)
7
+ * - Arrays (containing valid JSON values)
8
+ * - Strings
9
+ * - Numbers
10
+ * - Booleans
11
+ * - null
12
+ *
13
+ * String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered
14
+ * valid JSON and will return true.
15
+ *
16
+ * This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`.
17
+ *
18
+ * @param {unknown} value The value to check.
19
+ * @returns {boolean} Returns `true` if `value` is a valid JSON string, else `false`.
20
+ *
21
+ * @example
22
+ * isJSON('{"name":"John","age":30}'); // true
23
+ * isJSON('[1,2,3]'); // true
24
+ * isJSON('true'); // true
25
+ * isJSON('invalid json'); // false
26
+ * isJSON({ name: 'John' }); // false (not a string)
27
+ * isJSON(null); // false (not a string)
28
+ */
29
+ declare function isJSON(value: unknown): value is string;
30
+
31
+ export { isJSON };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON string.
3
+ *
4
+ * A valid JSON string is one that can be successfully parsed using `JSON.parse()`. According to JSON
5
+ * specifications, valid JSON can represent:
6
+ * - Objects (with string keys and valid JSON values)
7
+ * - Arrays (containing valid JSON values)
8
+ * - Strings
9
+ * - Numbers
10
+ * - Booleans
11
+ * - null
12
+ *
13
+ * String values like `"null"`, `"true"`, `"false"`, and numeric strings (e.g., `"42"`) are considered
14
+ * valid JSON and will return true.
15
+ *
16
+ * This function serves as a type guard in TypeScript, narrowing the type of the argument to `string`.
17
+ *
18
+ * @param {unknown} value The value to check.
19
+ * @returns {boolean} Returns `true` if `value` is a valid JSON string, else `false`.
20
+ *
21
+ * @example
22
+ * isJSON('{"name":"John","age":30}'); // true
23
+ * isJSON('[1,2,3]'); // true
24
+ * isJSON('true'); // true
25
+ * isJSON('invalid json'); // false
26
+ * isJSON({ name: 'John' }); // false (not a string)
27
+ * isJSON(null); // false (not a string)
28
+ */
29
+ declare function isJSON(value: unknown): value is string;
30
+
31
+ export { isJSON };
@@ -0,0 +1,14 @@
1
+ function isJSON(value) {
2
+ if (typeof value !== 'string') {
3
+ return false;
4
+ }
5
+ try {
6
+ JSON.parse(value);
7
+ return true;
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ export { isJSON };
@@ -9,6 +9,7 @@ export { lowerCase } from './lowerCase.mjs';
9
9
  export { lowerFirst } from './lowerFirst.mjs';
10
10
  export { pad } from './pad.mjs';
11
11
  export { pascalCase } from './pascalCase.mjs';
12
+ export { reverseString } from './reverseString.mjs';
12
13
  export { snakeCase } from './snakeCase.mjs';
13
14
  export { startCase } from './startCase.mjs';
14
15
  export { trim } from './trim.mjs';
@@ -9,6 +9,7 @@ export { lowerCase } from './lowerCase.js';
9
9
  export { lowerFirst } from './lowerFirst.js';
10
10
  export { pad } from './pad.js';
11
11
  export { pascalCase } from './pascalCase.js';
12
+ export { reverseString } from './reverseString.js';
12
13
  export { snakeCase } from './snakeCase.js';
13
14
  export { startCase } from './startCase.js';
14
15
  export { trim } from './trim.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const upperFirst = require('../_chunk/upperFirst-CorAVn.js');
5
+ const upperFirst = require('../_chunk/upperFirst-nA5L7X.js');
6
6
 
7
7
  function startCase(str) {
8
8
  const words = upperFirst.words(str.trim());
@@ -28,6 +28,7 @@ exports.lowerCase = upperFirst.lowerCase;
28
28
  exports.lowerFirst = upperFirst.lowerFirst;
29
29
  exports.pad = upperFirst.pad;
30
30
  exports.pascalCase = upperFirst.pascalCase;
31
+ exports.reverseString = upperFirst.reverseString;
31
32
  exports.snakeCase = upperFirst.snakeCase;
32
33
  exports.trim = upperFirst.trim;
33
34
  exports.trimEnd = upperFirst.trimEnd;
@@ -9,6 +9,7 @@ export { lowerCase } from './lowerCase.mjs';
9
9
  export { lowerFirst } from './lowerFirst.mjs';
10
10
  export { pad } from './pad.mjs';
11
11
  export { pascalCase } from './pascalCase.mjs';
12
+ export { reverseString } from './reverseString.mjs';
12
13
  export { snakeCase } from './snakeCase.mjs';
13
14
  export { startCase } from './startCase.mjs';
14
15
  export { trim } from './trim.mjs';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Reverses a given string.
3
+ *
4
+ * This function takes a string as input and returns a new string that is the reverse of the input.
5
+ *
6
+ * @param {string} value - The string that is to be reversed.
7
+ * @returns {string} - The reversed string.
8
+ *
9
+ * @example
10
+ * const reversedStr1 = reverseString('hello') // returns 'olleh'
11
+ * const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP'
12
+ * const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof'
13
+ */
14
+ declare function reverseString(value: string): string;
15
+
16
+ export { reverseString };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Reverses a given string.
3
+ *
4
+ * This function takes a string as input and returns a new string that is the reverse of the input.
5
+ *
6
+ * @param {string} value - The string that is to be reversed.
7
+ * @returns {string} - The reversed string.
8
+ *
9
+ * @example
10
+ * const reversedStr1 = reverseString('hello') // returns 'olleh'
11
+ * const reversedStr2 = reverseString('PascalCase') // returns 'esaClacsaP'
12
+ * const reversedStr3 = reverseString('foo 😄 bar') // returns 'rab 😄 oof'
13
+ */
14
+ declare function reverseString(value: string): string;
15
+
16
+ export { reverseString };
@@ -0,0 +1,5 @@
1
+ function reverseString(value) {
2
+ return [...value].reverse().join('');
3
+ }
4
+
5
+ export { reverseString };
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.32.0",
4
+ "version": "1.33.0-dev.1025+fd9472d4",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -14,6 +14,7 @@
14
14
  "benchmarks"
15
15
  ],
16
16
  "packageManager": "yarn@4.2.2",
17
+ "react-native": "./dist/index.js",
17
18
  "exports": {
18
19
  ".": {
19
20
  "import": {