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
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Computes the difference between
|
|
3
|
-
*
|
|
4
|
-
* This function takes two arrays and returns a new array containing the elements
|
|
5
|
-
* that are present in the first array but not in the second array. It effectively
|
|
6
|
-
* filters out any elements from the first array that also appear in the second array.
|
|
2
|
+
* Computes the difference between an array and multiple arrays.
|
|
7
3
|
*
|
|
8
4
|
* @template T
|
|
9
|
-
* @param {T[]}
|
|
5
|
+
* @param {T[]} arr - The primary array from which to derive the difference. This is the main array
|
|
10
6
|
* from which elements will be compared and filtered.
|
|
11
|
-
* @param {T[]}
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
16
|
-
* @returns {T[]} A new array containing the elements that are present in the first array but not
|
|
17
|
-
* in the second array.
|
|
7
|
+
* @param {...T[]} values - Multiple arrays containing elements to be excluded from the primary array.
|
|
8
|
+
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
|
|
9
|
+
* If a match is found, that element will be excluded from the result.
|
|
10
|
+
* @returns {T[]} A new array containing the elements that are present in the primary array but not
|
|
11
|
+
* in the flattened array.
|
|
18
12
|
*
|
|
19
13
|
* @example
|
|
20
14
|
* const array1 = [1, 2, 3, 4, 5];
|
|
21
15
|
* const array2 = [2, 4];
|
|
22
|
-
* const
|
|
23
|
-
*
|
|
16
|
+
* const array3 = [5, 6];
|
|
17
|
+
* const result = difference(array1, array2, array3);
|
|
18
|
+
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
|
|
24
19
|
*/
|
|
25
20
|
declare function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[];
|
|
26
21
|
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Computes the difference between
|
|
3
|
-
*
|
|
4
|
-
* This function takes two arrays and returns a new array containing the elements
|
|
5
|
-
* that are present in the first array but not in the second array. It effectively
|
|
6
|
-
* filters out any elements from the first array that also appear in the second array.
|
|
2
|
+
* Computes the difference between an array and multiple arrays.
|
|
7
3
|
*
|
|
8
4
|
* @template T
|
|
9
|
-
* @param {T[]}
|
|
5
|
+
* @param {T[]} arr - The primary array from which to derive the difference. This is the main array
|
|
10
6
|
* from which elements will be compared and filtered.
|
|
11
|
-
* @param {T[]}
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
16
|
-
* @returns {T[]} A new array containing the elements that are present in the first array but not
|
|
17
|
-
* in the second array.
|
|
7
|
+
* @param {...T[]} values - Multiple arrays containing elements to be excluded from the primary array.
|
|
8
|
+
* These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.
|
|
9
|
+
* If a match is found, that element will be excluded from the result.
|
|
10
|
+
* @returns {T[]} A new array containing the elements that are present in the primary array but not
|
|
11
|
+
* in the flattened array.
|
|
18
12
|
*
|
|
19
13
|
* @example
|
|
20
14
|
* const array1 = [1, 2, 3, 4, 5];
|
|
21
15
|
* const array2 = [2, 4];
|
|
22
|
-
* const
|
|
23
|
-
*
|
|
16
|
+
* const array3 = [5, 6];
|
|
17
|
+
* const result = difference(array1, array2, array3);
|
|
18
|
+
* // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.
|
|
24
19
|
*/
|
|
25
20
|
declare function difference<T>(arr: readonly T[], ...values: Array<readonly T[]>): T[];
|
|
26
21
|
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -126,8 +126,6 @@ export { bindKey } from './function/bindKey.mjs';
|
|
|
126
126
|
export { rest } from './function/rest.mjs';
|
|
127
127
|
export { spread } from './function/spread.mjs';
|
|
128
128
|
export { attempt } from './function/attempt.mjs';
|
|
129
|
-
export { conforms } from './function/conforms.mjs';
|
|
130
|
-
export { conformsTo } from './function/conformsTo.mjs';
|
|
131
129
|
export { get } from './object/get.mjs';
|
|
132
130
|
export { set } from './object/set.mjs';
|
|
133
131
|
export { has } from './object/has.mjs';
|
|
@@ -152,6 +150,8 @@ export { matches } from './predicate/matches.mjs';
|
|
|
152
150
|
export { matchesProperty } from './predicate/matchesProperty.mjs';
|
|
153
151
|
export { isWeakMap } from './predicate/isWeakMap.mjs';
|
|
154
152
|
export { isWeakSet } from './predicate/isWeakSet.mjs';
|
|
153
|
+
export { conforms } from './predicate/conforms.mjs';
|
|
154
|
+
export { conformsTo } from './predicate/conformsTo.mjs';
|
|
155
155
|
export { startsWith } from './string/startsWith.mjs';
|
|
156
156
|
export { endsWith } from './string/endsWith.mjs';
|
|
157
157
|
export { padStart } from './string/padStart.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -126,8 +126,6 @@ export { bindKey } from './function/bindKey.js';
|
|
|
126
126
|
export { rest } from './function/rest.js';
|
|
127
127
|
export { spread } from './function/spread.js';
|
|
128
128
|
export { attempt } from './function/attempt.js';
|
|
129
|
-
export { conforms } from './function/conforms.js';
|
|
130
|
-
export { conformsTo } from './function/conformsTo.js';
|
|
131
129
|
export { get } from './object/get.js';
|
|
132
130
|
export { set } from './object/set.js';
|
|
133
131
|
export { has } from './object/has.js';
|
|
@@ -152,6 +150,8 @@ export { matches } from './predicate/matches.js';
|
|
|
152
150
|
export { matchesProperty } from './predicate/matchesProperty.js';
|
|
153
151
|
export { isWeakMap } from './predicate/isWeakMap.js';
|
|
154
152
|
export { isWeakSet } from './predicate/isWeakSet.js';
|
|
153
|
+
export { conforms } from './predicate/conforms.js';
|
|
154
|
+
export { conformsTo } from './predicate/conformsTo.js';
|
|
155
155
|
export { startsWith } from './string/startsWith.js';
|
|
156
156
|
export { endsWith } from './string/endsWith.js';
|
|
157
157
|
export { padStart } from './string/padStart.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const zipWith = require('../_chunk/zipWith-CaTQLt.js');
|
|
6
6
|
const promise_index = require('../_chunk/index-BGZDR9.js');
|
|
7
|
-
const
|
|
8
|
-
const cloneDeep$1 = require('../_chunk/cloneDeep-B7ltZL.js');
|
|
7
|
+
const rest$1 = require('../_chunk/rest-CXt9w3.js');
|
|
9
8
|
const math_index = require('../math/index.js');
|
|
10
9
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
|
-
const toMerged = require('../_chunk/toMerged-
|
|
12
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-
|
|
13
|
-
const isTypedArray$1 = require('../_chunk/isTypedArray-
|
|
10
|
+
const toMerged = require('../_chunk/toMerged-DN1PPP.js');
|
|
11
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-CogETi.js');
|
|
12
|
+
const isTypedArray$1 = require('../_chunk/isTypedArray-Dsrnb1.js');
|
|
14
13
|
const string_index = require('../string/index.js');
|
|
15
14
|
|
|
16
15
|
function chunk(arr, size = 1) {
|
|
@@ -240,7 +239,7 @@ function isMatch(target, source) {
|
|
|
240
239
|
}
|
|
241
240
|
|
|
242
241
|
function matches(source) {
|
|
243
|
-
source =
|
|
242
|
+
source = toMerged.cloneDeep(source);
|
|
244
243
|
return (target) => {
|
|
245
244
|
return isMatch(target, source);
|
|
246
245
|
};
|
|
@@ -248,25 +247,25 @@ function matches(source) {
|
|
|
248
247
|
|
|
249
248
|
function cloneDeep(obj) {
|
|
250
249
|
if (typeof obj !== 'object') {
|
|
251
|
-
return
|
|
250
|
+
return toMerged.cloneDeep(obj);
|
|
252
251
|
}
|
|
253
252
|
switch (Object.prototype.toString.call(obj)) {
|
|
254
253
|
case isWeakSet$1.numberTag:
|
|
255
254
|
case isWeakSet$1.stringTag:
|
|
256
255
|
case isWeakSet$1.booleanTag: {
|
|
257
256
|
const result = new obj.constructor(obj?.valueOf());
|
|
258
|
-
|
|
257
|
+
toMerged.copyProperties(result, obj);
|
|
259
258
|
return result;
|
|
260
259
|
}
|
|
261
260
|
case isWeakSet$1.argumentsTag: {
|
|
262
261
|
const result = {};
|
|
263
|
-
|
|
262
|
+
toMerged.copyProperties(result, obj);
|
|
264
263
|
result.length = obj.length;
|
|
265
264
|
result[Symbol.iterator] = obj[Symbol.iterator];
|
|
266
265
|
return result;
|
|
267
266
|
}
|
|
268
267
|
default: {
|
|
269
|
-
return
|
|
268
|
+
return toMerged.cloneDeep(obj);
|
|
270
269
|
}
|
|
271
270
|
}
|
|
272
271
|
}
|
|
@@ -646,7 +645,7 @@ function ary(func, n = func.length, guard) {
|
|
|
646
645
|
if (Number.isNaN(n) || n < 0) {
|
|
647
646
|
n = 0;
|
|
648
647
|
}
|
|
649
|
-
return
|
|
648
|
+
return rest$1.ary(func, n);
|
|
650
649
|
}
|
|
651
650
|
|
|
652
651
|
function bind(func, thisObj, ...partialArgs) {
|
|
@@ -706,7 +705,7 @@ function rest(func, start = func.length - 1) {
|
|
|
706
705
|
if (Number.isNaN(start) || start < 0) {
|
|
707
706
|
start = func.length - 1;
|
|
708
707
|
}
|
|
709
|
-
return
|
|
708
|
+
return rest$1.rest(func, start);
|
|
710
709
|
}
|
|
711
710
|
|
|
712
711
|
function spread(func, argsIndex = 0) {
|
|
@@ -733,23 +732,6 @@ function attempt(func, ...args) {
|
|
|
733
732
|
}
|
|
734
733
|
}
|
|
735
734
|
|
|
736
|
-
function conformsTo(object, source) {
|
|
737
|
-
if (source == null) {
|
|
738
|
-
return true;
|
|
739
|
-
}
|
|
740
|
-
if (object == null) {
|
|
741
|
-
return Object.keys(source).length === 0;
|
|
742
|
-
}
|
|
743
|
-
return conformsTo$1.conformsTo(object, source);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function conforms(source) {
|
|
747
|
-
source = cloneDeep$1.cloneDeep(source);
|
|
748
|
-
return function (object) {
|
|
749
|
-
return conformsTo(object, source);
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
|
|
753
735
|
function mapKeys(object, getNewKey) {
|
|
754
736
|
getNewKey = getNewKey ?? identity;
|
|
755
737
|
switch (typeof getNewKey) {
|
|
@@ -877,19 +859,19 @@ function mergeWithDeep(target, source, merge, stack) {
|
|
|
877
859
|
}
|
|
878
860
|
|
|
879
861
|
function merge(object, ...sources) {
|
|
880
|
-
return mergeWith(object, ...sources,
|
|
862
|
+
return mergeWith(object, ...sources, rest$1.noop);
|
|
881
863
|
}
|
|
882
864
|
|
|
883
865
|
function isArrayLike(value) {
|
|
884
866
|
return value != null && typeof value !== 'function' && isWeakSet$1.isLength(value.length);
|
|
885
867
|
}
|
|
886
868
|
|
|
887
|
-
function fromPairs(
|
|
888
|
-
if (!isArrayLike(
|
|
869
|
+
function fromPairs(pairs) {
|
|
870
|
+
if (!isArrayLike(pairs) && !(pairs instanceof Map)) {
|
|
889
871
|
return {};
|
|
890
872
|
}
|
|
891
873
|
const result = {};
|
|
892
|
-
for (const [key, value] of
|
|
874
|
+
for (const [key, value] of pairs) {
|
|
893
875
|
result[key] = value;
|
|
894
876
|
}
|
|
895
877
|
return result;
|
|
@@ -931,6 +913,30 @@ function isWeakSet(value) {
|
|
|
931
913
|
return isWeakSet$1.isWeakSet(value);
|
|
932
914
|
}
|
|
933
915
|
|
|
916
|
+
function conformsTo(target, source) {
|
|
917
|
+
if (source == null) {
|
|
918
|
+
return true;
|
|
919
|
+
}
|
|
920
|
+
if (target == null) {
|
|
921
|
+
return Object.keys(source).length === 0;
|
|
922
|
+
}
|
|
923
|
+
for (const key of Object.keys(source)) {
|
|
924
|
+
const predicate = source[key];
|
|
925
|
+
const value = target[key];
|
|
926
|
+
if ((value === undefined && !(key in target)) || !predicate(value)) {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function conforms(source) {
|
|
934
|
+
source = toMerged.cloneDeep(source);
|
|
935
|
+
return function (object) {
|
|
936
|
+
return conformsTo(object, source);
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
|
|
934
940
|
function startsWith(str, target, position = 0) {
|
|
935
941
|
return str.startsWith(target, position);
|
|
936
942
|
}
|
|
@@ -1031,18 +1037,17 @@ exports.TimeoutError = promise_index.TimeoutError;
|
|
|
1031
1037
|
exports.delay = promise_index.delay;
|
|
1032
1038
|
exports.timeout = promise_index.timeout;
|
|
1033
1039
|
exports.withTimeout = promise_index.withTimeout;
|
|
1034
|
-
exports.after =
|
|
1035
|
-
exports.before =
|
|
1036
|
-
exports.debounce =
|
|
1037
|
-
exports.memoize =
|
|
1038
|
-
exports.negate =
|
|
1039
|
-
exports.noop =
|
|
1040
|
-
exports.once =
|
|
1041
|
-
exports.partial =
|
|
1042
|
-
exports.partialRight =
|
|
1043
|
-
exports.throttle =
|
|
1044
|
-
exports.unary =
|
|
1045
|
-
exports.cloneDeep = cloneDeep$1.cloneDeep;
|
|
1040
|
+
exports.after = rest$1.after;
|
|
1041
|
+
exports.before = rest$1.before;
|
|
1042
|
+
exports.debounce = rest$1.debounce;
|
|
1043
|
+
exports.memoize = rest$1.memoize;
|
|
1044
|
+
exports.negate = rest$1.negate;
|
|
1045
|
+
exports.noop = rest$1.noop;
|
|
1046
|
+
exports.once = rest$1.once;
|
|
1047
|
+
exports.partial = rest$1.partial;
|
|
1048
|
+
exports.partialRight = rest$1.partialRight;
|
|
1049
|
+
exports.throttle = rest$1.throttle;
|
|
1050
|
+
exports.unary = rest$1.unary;
|
|
1046
1051
|
exports.clamp = math_index.clamp;
|
|
1047
1052
|
exports.inRange = math_index.inRange;
|
|
1048
1053
|
exports.mean = math_index.mean;
|
|
@@ -1054,6 +1059,7 @@ exports.sumBy = math_index.sumBy;
|
|
|
1054
1059
|
exports.random = randomInt.random;
|
|
1055
1060
|
exports.randomInt = randomInt.randomInt;
|
|
1056
1061
|
exports.clone = toMerged.clone;
|
|
1062
|
+
exports.cloneDeep = toMerged.cloneDeep;
|
|
1057
1063
|
exports.flattenObject = toMerged.flattenObject;
|
|
1058
1064
|
exports.invert = toMerged.invert;
|
|
1059
1065
|
exports.isObjectLike = toMerged.isObjectLike;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -61,7 +61,6 @@ export { memoize } from '../function/memoize.mjs';
|
|
|
61
61
|
export { unary } from '../function/unary.mjs';
|
|
62
62
|
export { partial } from '../function/partial.mjs';
|
|
63
63
|
export { partialRight } from '../function/partialRight.mjs';
|
|
64
|
-
export { cloneDeep } from '../object/cloneDeep.mjs';
|
|
65
64
|
export { clamp } from '../math/clamp.mjs';
|
|
66
65
|
export { inRange } from '../math/inRange.mjs';
|
|
67
66
|
export { mean } from '../math/mean.mjs';
|
|
@@ -79,6 +78,7 @@ export { pickBy } from '../object/pickBy.mjs';
|
|
|
79
78
|
export { invert } from '../object/invert.mjs';
|
|
80
79
|
export { clone } from '../object/clone.mjs';
|
|
81
80
|
export { flattenObject } from '../object/flattenObject.mjs';
|
|
81
|
+
export { cloneDeep } from '../object/cloneDeep.mjs';
|
|
82
82
|
export { isObjectLike } from './predicate/isObjectLike.mjs';
|
|
83
83
|
export { toMerged } from '../object/toMerged.mjs';
|
|
84
84
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
@@ -127,8 +127,6 @@ export { bindKey } from './function/bindKey.mjs';
|
|
|
127
127
|
export { rest } from './function/rest.mjs';
|
|
128
128
|
export { spread } from './function/spread.mjs';
|
|
129
129
|
export { attempt } from './function/attempt.mjs';
|
|
130
|
-
export { conforms } from './function/conforms.mjs';
|
|
131
|
-
export { conformsTo } from './function/conformsTo.mjs';
|
|
132
130
|
export { get } from './object/get.mjs';
|
|
133
131
|
export { set } from './object/set.mjs';
|
|
134
132
|
export { has } from './object/has.mjs';
|
|
@@ -152,6 +150,8 @@ export { matches } from './predicate/matches.mjs';
|
|
|
152
150
|
export { matchesProperty } from './predicate/matchesProperty.mjs';
|
|
153
151
|
export { isWeakMap } from './predicate/isWeakMap.mjs';
|
|
154
152
|
export { isWeakSet } from './predicate/isWeakSet.mjs';
|
|
153
|
+
export { conforms } from './predicate/conforms.mjs';
|
|
154
|
+
export { conformsTo } from './predicate/conformsTo.mjs';
|
|
155
155
|
export { startsWith } from './string/startsWith.mjs';
|
|
156
156
|
export { endsWith } from './string/endsWith.mjs';
|
|
157
157
|
export { padStart } from './string/padStart.mjs';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
2
2
|
|
|
3
|
-
function fromPairs(
|
|
4
|
-
if (!isArrayLike(
|
|
3
|
+
function fromPairs(pairs) {
|
|
4
|
+
if (!isArrayLike(pairs) && !(pairs instanceof Map)) {
|
|
5
5
|
return {};
|
|
6
6
|
}
|
|
7
7
|
const result = {};
|
|
8
|
-
for (const [key, value] of
|
|
8
|
+
for (const [key, value] of pairs) {
|
|
9
9
|
result[key] = value;
|
|
10
10
|
}
|
|
11
11
|
return result;
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
|
|
7
7
|
* @returns {(object: Record<PropertyKey, any>) => boolean} Returns the new spec function.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const isPositive = (n) => n > 0;
|
|
11
|
+
* const isEven = (n) => n % 2 === 0;
|
|
12
|
+
* const predicates = { a: isPositive, b: isEven };
|
|
13
|
+
* const conform = conforms(predicates);
|
|
14
|
+
*
|
|
15
|
+
* console.log(conform({ a: 2, b: 4 })); // true
|
|
16
|
+
* console.log(conform({ a: -1, b: 4 })); // false
|
|
17
|
+
* console.log(conform({ a: 2, b: 3 })); // false
|
|
18
|
+
* console.log(conform({ a: 0, b: 2 })); // false
|
|
8
19
|
*/
|
|
9
20
|
declare function conforms(source: Record<PropertyKey, (value: any) => boolean>): (object: Record<PropertyKey, any>) => boolean;
|
|
10
21
|
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
|
|
7
7
|
* @returns {(object: Record<PropertyKey, any>) => boolean} Returns the new spec function.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const isPositive = (n) => n > 0;
|
|
11
|
+
* const isEven = (n) => n % 2 === 0;
|
|
12
|
+
* const predicates = { a: isPositive, b: isEven };
|
|
13
|
+
* const conform = conforms(predicates);
|
|
14
|
+
*
|
|
15
|
+
* console.log(conform({ a: 2, b: 4 })); // true
|
|
16
|
+
* console.log(conform({ a: -1, b: 4 })); // false
|
|
17
|
+
* console.log(conform({ a: 2, b: 3 })); // false
|
|
18
|
+
* console.log(conform({ a: 0, b: 2 })); // false
|
|
8
19
|
*/
|
|
9
20
|
declare function conforms(source: Record<PropertyKey, (value: any) => boolean>): (object: Record<PropertyKey, any>) => boolean;
|
|
10
21
|
|
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Note: This method is equivalent to `conforms` when source is partially applied.
|
|
5
5
|
*
|
|
6
|
-
* @param {Record<PropertyKey, any>}
|
|
6
|
+
* @param {Record<PropertyKey, any>} target The object to inspect.
|
|
7
7
|
* @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
|
|
8
8
|
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* const object = { 'a': 1, 'b': 2 };
|
|
13
|
+
* const source = {
|
|
14
|
+
* 'a': (n) => n > 0,
|
|
15
|
+
* 'b': (n) => n > 1
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* console.log(conformsTo(object, source)); // => true
|
|
19
|
+
*
|
|
20
|
+
* const source2 = {
|
|
21
|
+
* 'a': (n) => n > 1,
|
|
22
|
+
* 'b': (n) => n > 1
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* console.log(conformsTo(object, source2)); // => false
|
|
9
26
|
*/
|
|
10
|
-
declare function conformsTo(
|
|
27
|
+
declare function conformsTo(target: Record<PropertyKey, any>, source: Record<PropertyKey, (value: any) => boolean>): boolean;
|
|
11
28
|
|
|
12
29
|
export { conformsTo };
|
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Note: This method is equivalent to `conforms` when source is partially applied.
|
|
5
5
|
*
|
|
6
|
-
* @param {Record<PropertyKey, any>}
|
|
6
|
+
* @param {Record<PropertyKey, any>} target The object to inspect.
|
|
7
7
|
* @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
|
|
8
8
|
* @returns {boolean} Returns `true` if `object` conforms, else `false`.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* const object = { 'a': 1, 'b': 2 };
|
|
13
|
+
* const source = {
|
|
14
|
+
* 'a': (n) => n > 0,
|
|
15
|
+
* 'b': (n) => n > 1
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* console.log(conformsTo(object, source)); // => true
|
|
19
|
+
*
|
|
20
|
+
* const source2 = {
|
|
21
|
+
* 'a': (n) => n > 1,
|
|
22
|
+
* 'b': (n) => n > 1
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* console.log(conformsTo(object, source2)); // => false
|
|
9
26
|
*/
|
|
10
|
-
declare function conformsTo(
|
|
27
|
+
declare function conformsTo(target: Record<PropertyKey, any>, source: Record<PropertyKey, (value: any) => boolean>): boolean;
|
|
11
28
|
|
|
12
29
|
export { conformsTo };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function conformsTo(target, source) {
|
|
2
|
+
if (source == null) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
if (target == null) {
|
|
6
|
+
return Object.keys(source).length === 0;
|
|
7
|
+
}
|
|
8
|
+
for (const key of Object.keys(source)) {
|
|
9
|
+
const predicate = source[key];
|
|
10
|
+
const value = target[key];
|
|
11
|
+
if ((value === undefined && !(key in target)) || !predicate(value)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { conformsTo };
|
|
@@ -12,5 +12,3 @@ export { partial } from './partial.mjs';
|
|
|
12
12
|
export { partialRight } from './partialRight.mjs';
|
|
13
13
|
export { rest } from './rest.mjs';
|
|
14
14
|
export { spread } from './spread.mjs';
|
|
15
|
-
export { conforms } from './conforms.mjs';
|
|
16
|
-
export { conformsTo } from './conformsTo.mjs';
|
package/dist/function/index.d.ts
CHANGED
package/dist/function/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const cloneDeep = require('../_chunk/cloneDeep-B7ltZL.js');
|
|
5
|
+
const rest = require('../_chunk/rest-CXt9w3.js');
|
|
7
6
|
|
|
8
7
|
function spread(func) {
|
|
9
8
|
return function (argsArr) {
|
|
@@ -11,26 +10,17 @@ function spread(func) {
|
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
exports.negate = conformsTo.negate;
|
|
28
|
-
exports.noop = conformsTo.noop;
|
|
29
|
-
exports.once = conformsTo.once;
|
|
30
|
-
exports.partial = conformsTo.partial;
|
|
31
|
-
exports.partialRight = conformsTo.partialRight;
|
|
32
|
-
exports.rest = conformsTo.rest;
|
|
33
|
-
exports.throttle = conformsTo.throttle;
|
|
34
|
-
exports.unary = conformsTo.unary;
|
|
35
|
-
exports.conforms = conforms;
|
|
13
|
+
exports.after = rest.after;
|
|
14
|
+
exports.ary = rest.ary;
|
|
15
|
+
exports.before = rest.before;
|
|
16
|
+
exports.debounce = rest.debounce;
|
|
17
|
+
exports.memoize = rest.memoize;
|
|
18
|
+
exports.negate = rest.negate;
|
|
19
|
+
exports.noop = rest.noop;
|
|
20
|
+
exports.once = rest.once;
|
|
21
|
+
exports.partial = rest.partial;
|
|
22
|
+
exports.partialRight = rest.partialRight;
|
|
23
|
+
exports.rest = rest.rest;
|
|
24
|
+
exports.throttle = rest.throttle;
|
|
25
|
+
exports.unary = rest.unary;
|
|
36
26
|
exports.spread = spread;
|
package/dist/function/index.mjs
CHANGED
|
@@ -12,5 +12,3 @@ export { partial } from './partial.mjs';
|
|
|
12
12
|
export { partialRight } from './partialRight.mjs';
|
|
13
13
|
export { rest } from './rest.mjs';
|
|
14
14
|
export { spread } from './spread.mjs';
|
|
15
|
-
export { conforms } from './conforms.mjs';
|
|
16
|
-
export { conformsTo } from './conformsTo.mjs';
|
package/dist/index.d.mts
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';
|
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
|
|
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-
|
|
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-
|
|
16
|
-
const
|
|
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 =
|
|
86
|
-
exports.ary =
|
|
87
|
-
exports.before =
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
94
|
-
exports.
|
|
95
|
-
exports.
|
|
96
|
-
exports.
|
|
97
|
-
exports.
|
|
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 =
|
|
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';
|