es-toolkit 1.17.0-dev.548 → 1.17.0-dev.549
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.
- package/dist/_chunk/{isPlainObject-bK22pA.js → isTypedArray-Dsrnb1.js} +10 -0
- package/dist/_chunk/{isWeakSet-ChLbQW.js → isWeakSet-CogETi.js} +2 -2
- package/dist/_chunk/{conformsTo-lJfju7.js → rest-CXt9w3.js} +0 -12
- package/dist/_chunk/{toMerged-D0ydqe.js → toMerged-DN1PPP.js} +114 -4
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/array/difference.d.mts +10 -15
- package/dist/compat/array/difference.d.ts +10 -15
- package/dist/compat/index.d.mts +2 -2
- package/dist/compat/index.d.ts +2 -2
- package/dist/compat/index.js +51 -45
- package/dist/compat/index.mjs +3 -3
- package/dist/compat/object/fromPairs.mjs +3 -3
- package/dist/compat/{function → predicate}/conforms.d.mts +11 -0
- package/dist/compat/{function → predicate}/conforms.d.ts +11 -0
- package/dist/{function → compat/predicate}/conformsTo.d.mts +19 -2
- package/dist/{function → compat/predicate}/conformsTo.d.ts +19 -2
- package/dist/compat/predicate/conformsTo.mjs +18 -0
- package/dist/function/index.d.mts +0 -2
- package/dist/function/index.d.ts +0 -2
- package/dist/function/index.js +14 -24
- package/dist/function/index.mjs +0 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +19 -23
- package/dist/index.mjs +0 -2
- package/dist/object/index.js +2 -3
- package/dist/predicate/index.js +3 -4
- package/package.json +1 -1
- package/dist/_chunk/cloneDeep-B7ltZL.js +0 -115
- package/dist/_chunk/isTypedArray-DBjEP0.js +0 -12
- package/dist/compat/function/conformsTo.d.mts +0 -12
- package/dist/compat/function/conformsTo.d.ts +0 -12
- package/dist/compat/function/conformsTo.mjs +0 -15
- package/dist/function/conforms.d.mts +0 -11
- package/dist/function/conforms.d.ts +0 -11
- package/dist/function/conforms.mjs +0 -11
- package/dist/function/conformsTo.mjs +0 -12
- /package/dist/compat/{function → predicate}/conforms.mjs +0 -0
package/dist/object/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const toMerged = require('../_chunk/toMerged-
|
|
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;
|
package/dist/predicate/index.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const isWeakSet = require('../_chunk/isWeakSet-
|
|
6
|
-
const
|
|
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 =
|
|
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.
|
|
4
|
+
"version": "1.17.0-dev.549+22b8a800",
|
|
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 };
|
|
File without changes
|