es-toolkit 1.17.0-dev.548 → 1.17.0-dev.550

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 (42) hide show
  1. package/dist/_chunk/{isPlainObject-bK22pA.js → isTypedArray-Dsrnb1.js} +10 -0
  2. package/dist/_chunk/{isWeakSet-ChLbQW.js → isWeakSet-CogETi.js} +2 -2
  3. package/dist/_chunk/{conformsTo-lJfju7.js → rest-CXt9w3.js} +0 -12
  4. package/dist/_chunk/{toMerged-D0ydqe.js → toMerged-DN1PPP.js} +114 -4
  5. package/dist/browser.global.js +1 -1
  6. package/dist/browser.global.js.map +1 -1
  7. package/dist/compat/array/castArray.d.mts +29 -0
  8. package/dist/compat/array/castArray.d.ts +29 -0
  9. package/dist/compat/array/castArray.mjs +8 -0
  10. package/dist/compat/array/difference.d.mts +10 -15
  11. package/dist/compat/array/difference.d.ts +10 -15
  12. package/dist/compat/index.d.mts +3 -2
  13. package/dist/compat/index.d.ts +3 -2
  14. package/dist/compat/index.js +59 -45
  15. package/dist/compat/index.mjs +4 -3
  16. package/dist/compat/object/fromPairs.mjs +3 -3
  17. package/dist/compat/{function → predicate}/conforms.d.mts +11 -0
  18. package/dist/compat/{function → predicate}/conforms.d.ts +11 -0
  19. package/dist/{function → compat/predicate}/conformsTo.d.mts +19 -2
  20. package/dist/{function → compat/predicate}/conformsTo.d.ts +19 -2
  21. package/dist/compat/predicate/conformsTo.mjs +18 -0
  22. package/dist/function/index.d.mts +0 -2
  23. package/dist/function/index.d.ts +0 -2
  24. package/dist/function/index.js +14 -24
  25. package/dist/function/index.mjs +0 -2
  26. package/dist/index.d.mts +0 -2
  27. package/dist/index.d.ts +0 -2
  28. package/dist/index.js +19 -23
  29. package/dist/index.mjs +0 -2
  30. package/dist/object/index.js +2 -3
  31. package/dist/predicate/index.js +3 -4
  32. package/package.json +1 -1
  33. package/dist/_chunk/cloneDeep-B7ltZL.js +0 -115
  34. package/dist/_chunk/isTypedArray-DBjEP0.js +0 -12
  35. package/dist/compat/function/conformsTo.d.mts +0 -12
  36. package/dist/compat/function/conformsTo.d.ts +0 -12
  37. package/dist/compat/function/conformsTo.mjs +0 -15
  38. package/dist/function/conforms.d.mts +0 -11
  39. package/dist/function/conforms.d.ts +0 -11
  40. package/dist/function/conforms.mjs +0 -11
  41. package/dist/function/conformsTo.mjs +0 -12
  42. /package/dist/compat/{function → predicate}/conforms.mjs +0 -0
package/dist/index.d.ts CHANGED
@@ -71,8 +71,6 @@ export { partial } from './function/partial.js';
71
71
  export { partialRight } from './function/partialRight.js';
72
72
  export { rest } from './function/rest.js';
73
73
  export { spread } from './function/spread.js';
74
- export { conforms } from './function/conforms.js';
75
- export { conformsTo } from './function/conformsTo.js';
76
74
  export { clamp } from './math/clamp.js';
77
75
  export { inRange } from './math/inRange.js';
78
76
  export { mean } from './math/mean.js';
package/dist/index.js CHANGED
@@ -5,16 +5,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const zipWith = require('./_chunk/zipWith-CaTQLt.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const promise_index = require('./_chunk/index-BGZDR9.js');
8
- const conformsTo = require('./_chunk/conformsTo-lJfju7.js');
8
+ const rest = require('./_chunk/rest-CXt9w3.js');
9
9
  const function_index = require('./function/index.js');
10
10
  const math_index = require('./math/index.js');
11
11
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
12
- const toMerged = require('./_chunk/toMerged-D0ydqe.js');
13
- const cloneDeep = require('./_chunk/cloneDeep-B7ltZL.js');
12
+ const toMerged = require('./_chunk/toMerged-DN1PPP.js');
14
13
  const object_index = require('./object/index.js');
15
- const isWeakSet = require('./_chunk/isWeakSet-ChLbQW.js');
16
- const isPlainObject = require('./_chunk/isPlainObject-bK22pA.js');
17
- const isTypedArray = require('./_chunk/isTypedArray-DBjEP0.js');
14
+ const isWeakSet = require('./_chunk/isWeakSet-CogETi.js');
15
+ const isTypedArray = require('./_chunk/isTypedArray-Dsrnb1.js');
18
16
  const predicate_index = require('./predicate/index.js');
19
17
  const string_index = require('./string/index.js');
20
18
 
@@ -82,21 +80,19 @@ exports.TimeoutError = promise_index.TimeoutError;
82
80
  exports.delay = promise_index.delay;
83
81
  exports.timeout = promise_index.timeout;
84
82
  exports.withTimeout = promise_index.withTimeout;
85
- exports.after = conformsTo.after;
86
- exports.ary = conformsTo.ary;
87
- exports.before = conformsTo.before;
88
- exports.conformsTo = conformsTo.conformsTo;
89
- exports.debounce = conformsTo.debounce;
90
- exports.memoize = conformsTo.memoize;
91
- exports.negate = conformsTo.negate;
92
- exports.noop = conformsTo.noop;
93
- exports.once = conformsTo.once;
94
- exports.partial = conformsTo.partial;
95
- exports.partialRight = conformsTo.partialRight;
96
- exports.rest = conformsTo.rest;
97
- exports.throttle = conformsTo.throttle;
98
- exports.unary = conformsTo.unary;
99
- exports.conforms = function_index.conforms;
83
+ exports.after = rest.after;
84
+ exports.ary = rest.ary;
85
+ exports.before = rest.before;
86
+ exports.debounce = rest.debounce;
87
+ exports.memoize = rest.memoize;
88
+ exports.negate = rest.negate;
89
+ exports.noop = rest.noop;
90
+ exports.once = rest.once;
91
+ exports.partial = rest.partial;
92
+ exports.partialRight = rest.partialRight;
93
+ exports.rest = rest.rest;
94
+ exports.throttle = rest.throttle;
95
+ exports.unary = rest.unary;
100
96
  exports.spread = function_index.spread;
101
97
  exports.clamp = math_index.clamp;
102
98
  exports.inRange = math_index.inRange;
@@ -109,6 +105,7 @@ exports.sumBy = math_index.sumBy;
109
105
  exports.random = randomInt.random;
110
106
  exports.randomInt = randomInt.randomInt;
111
107
  exports.clone = toMerged.clone;
108
+ exports.cloneDeep = toMerged.cloneDeep;
112
109
  exports.flattenObject = toMerged.flattenObject;
113
110
  exports.invert = toMerged.invert;
114
111
  exports.mapKeys = toMerged.mapKeys;
@@ -119,7 +116,6 @@ exports.omitBy = toMerged.omitBy;
119
116
  exports.pick = toMerged.pick;
120
117
  exports.pickBy = toMerged.pickBy;
121
118
  exports.toMerged = toMerged.toMerged;
122
- exports.cloneDeep = cloneDeep.cloneDeep;
123
119
  exports.mergeWith = object_index.mergeWith;
124
120
  exports.isEqual = isWeakSet.isEqual;
125
121
  exports.isFunction = isWeakSet.isFunction;
@@ -130,7 +126,7 @@ exports.isNull = isWeakSet.isNull;
130
126
  exports.isUndefined = isWeakSet.isUndefined;
131
127
  exports.isWeakMap = isWeakSet.isWeakMap;
132
128
  exports.isWeakSet = isWeakSet.isWeakSet;
133
- exports.isPlainObject = isPlainObject.isPlainObject;
129
+ exports.isPlainObject = isTypedArray.isPlainObject;
134
130
  exports.isPrimitive = isTypedArray.isPrimitive;
135
131
  exports.isTypedArray = isTypedArray.isTypedArray;
136
132
  exports.isBoolean = predicate_index.isBoolean;
package/dist/index.mjs CHANGED
@@ -71,8 +71,6 @@ export { partial } from './function/partial.mjs';
71
71
  export { partialRight } from './function/partialRight.mjs';
72
72
  export { rest } from './function/rest.mjs';
73
73
  export { spread } from './function/spread.mjs';
74
- export { conforms } from './function/conforms.mjs';
75
- export { conformsTo } from './function/conformsTo.mjs';
76
74
  export { clamp } from './math/clamp.mjs';
77
75
  export { inRange } from './math/inRange.mjs';
78
76
  export { mean } from './math/mean.mjs';
@@ -2,8 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const toMerged = require('../_chunk/toMerged-D0ydqe.js');
6
- const cloneDeep = require('../_chunk/cloneDeep-B7ltZL.js');
5
+ const toMerged = require('../_chunk/toMerged-DN1PPP.js');
7
6
 
8
7
  function mergeWith(target, source, merge) {
9
8
  const sourceKeys = Object.keys(source);
@@ -29,6 +28,7 @@ function mergeWith(target, source, merge) {
29
28
  }
30
29
 
31
30
  exports.clone = toMerged.clone;
31
+ exports.cloneDeep = toMerged.cloneDeep;
32
32
  exports.flattenObject = toMerged.flattenObject;
33
33
  exports.invert = toMerged.invert;
34
34
  exports.mapKeys = toMerged.mapKeys;
@@ -39,5 +39,4 @@ exports.omitBy = toMerged.omitBy;
39
39
  exports.pick = toMerged.pick;
40
40
  exports.pickBy = toMerged.pickBy;
41
41
  exports.toMerged = toMerged.toMerged;
42
- exports.cloneDeep = cloneDeep.cloneDeep;
43
42
  exports.mergeWith = mergeWith;
@@ -2,9 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-ChLbQW.js');
6
- const isPlainObject = require('../_chunk/isPlainObject-bK22pA.js');
7
- const isTypedArray = require('../_chunk/isTypedArray-DBjEP0.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-CogETi.js');
6
+ const isTypedArray = require('../_chunk/isTypedArray-Dsrnb1.js');
8
7
 
9
8
  function isRegExp(value) {
10
9
  return value instanceof RegExp;
@@ -31,7 +30,7 @@ exports.isNull = isWeakSet.isNull;
31
30
  exports.isUndefined = isWeakSet.isUndefined;
32
31
  exports.isWeakMap = isWeakSet.isWeakMap;
33
32
  exports.isWeakSet = isWeakSet.isWeakSet;
34
- exports.isPlainObject = isPlainObject.isPlainObject;
33
+ exports.isPlainObject = isTypedArray.isPlainObject;
35
34
  exports.isPrimitive = isTypedArray.isPrimitive;
36
35
  exports.isTypedArray = isTypedArray.isTypedArray;
37
36
  exports.isBoolean = isBoolean;
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.17.0-dev.548+d430ecff",
4
+ "version": "1.17.0-dev.550+aa37cb7e",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1,115 +0,0 @@
1
- 'use strict';
2
-
3
- const isTypedArray = require('./isTypedArray-DBjEP0.js');
4
-
5
- function cloneDeep(obj) {
6
- return cloneDeepImpl(obj);
7
- }
8
- function cloneDeepImpl(obj, stack = new Map()) {
9
- if (isTypedArray.isPrimitive(obj)) {
10
- return obj;
11
- }
12
- if (stack.has(obj)) {
13
- return stack.get(obj);
14
- }
15
- if (Array.isArray(obj)) {
16
- const result = new Array(obj.length);
17
- stack.set(obj, result);
18
- for (let i = 0; i < obj.length; i++) {
19
- result[i] = cloneDeepImpl(obj[i], stack);
20
- }
21
- if (Object.prototype.hasOwnProperty.call(obj, 'index')) {
22
- result.index = obj.index;
23
- }
24
- if (Object.prototype.hasOwnProperty.call(obj, 'input')) {
25
- result.input = obj.input;
26
- }
27
- return result;
28
- }
29
- if (obj instanceof Date) {
30
- return new Date(obj.getTime());
31
- }
32
- if (obj instanceof RegExp) {
33
- const result = new RegExp(obj.source, obj.flags);
34
- result.lastIndex = obj.lastIndex;
35
- return result;
36
- }
37
- if (obj instanceof Map) {
38
- const result = new Map();
39
- stack.set(obj, result);
40
- for (const [key, value] of obj.entries()) {
41
- result.set(key, cloneDeepImpl(value, stack));
42
- }
43
- return result;
44
- }
45
- if (obj instanceof Set) {
46
- const result = new Set();
47
- stack.set(obj, result);
48
- for (const value of obj.values()) {
49
- result.add(cloneDeepImpl(value, stack));
50
- }
51
- return result;
52
- }
53
- if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {
54
- return obj.subarray();
55
- }
56
- if (isTypedArray.isTypedArray(obj)) {
57
- const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);
58
- stack.set(obj, result);
59
- for (let i = 0; i < obj.length; i++) {
60
- result[i] = cloneDeepImpl(obj[i], stack);
61
- }
62
- return result;
63
- }
64
- if (obj instanceof ArrayBuffer || (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)) {
65
- return obj.slice(0);
66
- }
67
- if (obj instanceof DataView) {
68
- const result = new DataView(obj.buffer.slice(0));
69
- stack.set(obj, result);
70
- copyProperties(result, obj, stack);
71
- return result;
72
- }
73
- if (typeof File !== 'undefined' && obj instanceof File) {
74
- const result = new File([obj], obj.name, { type: obj.type });
75
- stack.set(obj, result);
76
- copyProperties(result, obj, stack);
77
- return result;
78
- }
79
- if (obj instanceof Blob) {
80
- const result = new Blob([obj], { type: obj.type });
81
- stack.set(obj, result);
82
- copyProperties(result, obj, stack);
83
- return result;
84
- }
85
- if (obj instanceof Error) {
86
- const result = new obj.constructor();
87
- stack.set(obj, result);
88
- result.message = obj.message;
89
- result.name = obj.name;
90
- result.stack = obj.stack;
91
- result.cause = obj.cause;
92
- copyProperties(result, obj, stack);
93
- return result;
94
- }
95
- if (typeof obj === 'object' && obj !== null) {
96
- const result = {};
97
- stack.set(obj, result);
98
- copyProperties(result, obj, stack);
99
- return result;
100
- }
101
- return obj;
102
- }
103
- function copyProperties(target, source, stack) {
104
- const keys = Object.keys(source);
105
- for (let i = 0; i < keys.length; i++) {
106
- const key = keys[i];
107
- const descriptor = Object.getOwnPropertyDescriptor(source, key);
108
- if (descriptor?.writable || descriptor?.set) {
109
- target[key] = cloneDeepImpl(source[key], stack);
110
- }
111
- }
112
- }
113
-
114
- exports.cloneDeep = cloneDeep;
115
- exports.copyProperties = copyProperties;
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- function isPrimitive(value) {
4
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
5
- }
6
-
7
- function isTypedArray(x) {
8
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
9
- }
10
-
11
- exports.isPrimitive = isPrimitive;
12
- exports.isTypedArray = isTypedArray;
@@ -1,12 +0,0 @@
1
- /**
2
- * Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
3
- *
4
- * Note: This method is equivalent to `conforms` when source is partially applied.
5
- *
6
- * @param {Record<PropertyKey, any>} object The object to inspect.
7
- * @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
8
- * @returns {boolean} Returns `true` if `object` conforms, else `false`.
9
- */
10
- declare function conformsTo(object: Record<PropertyKey, any>, source: Record<PropertyKey, (value: any) => boolean>): boolean;
11
-
12
- export { conformsTo };
@@ -1,12 +0,0 @@
1
- /**
2
- * Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.
3
- *
4
- * Note: This method is equivalent to `conforms` when source is partially applied.
5
- *
6
- * @param {Record<PropertyKey, any>} object The object to inspect.
7
- * @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
8
- * @returns {boolean} Returns `true` if `object` conforms, else `false`.
9
- */
10
- declare function conformsTo(object: Record<PropertyKey, any>, source: Record<PropertyKey, (value: any) => boolean>): boolean;
11
-
12
- export { conformsTo };
@@ -1,15 +0,0 @@
1
- import '../../function/partial.mjs';
2
- import '../../function/partialRight.mjs';
3
- import { conformsTo as conformsTo$1 } from '../../function/conformsTo.mjs';
4
-
5
- function conformsTo(object, source) {
6
- if (source == null) {
7
- return true;
8
- }
9
- if (object == null) {
10
- return Object.keys(source).length === 0;
11
- }
12
- return conformsTo$1(object, source);
13
- }
14
-
15
- export { conformsTo };
@@ -1,11 +0,0 @@
1
- /**
2
- * Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
3
- *
4
- * Note: The created function is equivalent to `conformsTo` with source partially applied.
5
- *
6
- * @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
7
- * @returns {(object: Record<PropertyKey, any>) => boolean} Returns the new spec function.
8
- */
9
- declare function conforms(source: Record<PropertyKey, (value: any) => boolean>): (object: Record<PropertyKey, any>) => boolean;
10
-
11
- export { conforms };
@@ -1,11 +0,0 @@
1
- /**
2
- * Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
3
- *
4
- * Note: The created function is equivalent to `conformsTo` with source partially applied.
5
- *
6
- * @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
7
- * @returns {(object: Record<PropertyKey, any>) => boolean} Returns the new spec function.
8
- */
9
- declare function conforms(source: Record<PropertyKey, (value: any) => boolean>): (object: Record<PropertyKey, any>) => boolean;
10
-
11
- export { conforms };
@@ -1,11 +0,0 @@
1
- import { conformsTo } from './conformsTo.mjs';
2
- import { cloneDeep } from '../object/cloneDeep.mjs';
3
-
4
- function conforms(source) {
5
- source = cloneDeep(source);
6
- return function (object) {
7
- return conformsTo(object, source);
8
- };
9
- }
10
-
11
- export { conforms };
@@ -1,12 +0,0 @@
1
- function conformsTo(object, source) {
2
- for (const key of Object.keys(source)) {
3
- const predicate = source[key];
4
- const value = object[key];
5
- if ((value === undefined && !(key in object)) || !predicate(value)) {
6
- return false;
7
- }
8
- }
9
- return true;
10
- }
11
-
12
- export { conformsTo };