is-kit 1.16.0 → 1.16.1
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/README.md +1 -1
- package/dist/index.js +13 -11
- package/dist/index.mjs +13 -11
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -547,6 +547,15 @@ const everyKeyValueEntry = (entries, predicate) => {
|
|
|
547
547
|
for (const [key, value] of entries) if (!predicate(key, value)) return false;
|
|
548
548
|
return true;
|
|
549
549
|
};
|
|
550
|
+
const hasTupleValues = (values, predicates) => {
|
|
551
|
+
if (values.length !== predicates.length) return false;
|
|
552
|
+
for (let index = 0; index < predicates.length; index += 1) {
|
|
553
|
+
const predicate = predicates[index];
|
|
554
|
+
if (!predicate(values[index])) return false;
|
|
555
|
+
}
|
|
556
|
+
return true;
|
|
557
|
+
};
|
|
558
|
+
const hasOwnEnumerableEntries = (values, keyPredicate, valuePredicate) => everyIterableValue(Object.keys(values), (key) => keyPredicate(key) && valuePredicate(values[key]));
|
|
550
559
|
/**
|
|
551
560
|
* Checks whether every array element satisfies the provided predicate.
|
|
552
561
|
*
|
|
@@ -575,14 +584,7 @@ const everyBrandedArrayValue = (values, predicate) => {
|
|
|
575
584
|
* @param predicates Predicates aligned to each tuple index.
|
|
576
585
|
* @returns Whether lengths match and each index passes.
|
|
577
586
|
*/
|
|
578
|
-
const everyTupleValue = (values, predicates) =>
|
|
579
|
-
if (values.length !== predicates.length) return false;
|
|
580
|
-
for (let index = 0; index < predicates.length; index += 1) {
|
|
581
|
-
const predicate = predicates[index];
|
|
582
|
-
if (!predicate(values[index])) return false;
|
|
583
|
-
}
|
|
584
|
-
return true;
|
|
585
|
-
};
|
|
587
|
+
const everyTupleValue = (values, predicates) => hasTupleValues(values, predicates);
|
|
586
588
|
/**
|
|
587
589
|
* Checks whether every set value satisfies the provided predicate.
|
|
588
590
|
*
|
|
@@ -625,7 +627,7 @@ const everyBrandedMapEntry = (values, keyPredicate, valuePredicate) => everyKeyV
|
|
|
625
627
|
* @param valuePredicate Predicate applied to each corresponding value.
|
|
626
628
|
* @returns Whether all enumerable entries satisfy their predicates.
|
|
627
629
|
*/
|
|
628
|
-
const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) =>
|
|
630
|
+
const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => hasOwnEnumerableEntries(values, keyPredicate, valuePredicate);
|
|
629
631
|
//#endregion
|
|
630
632
|
//#region src/core/combinators/array.ts
|
|
631
633
|
/**
|
|
@@ -826,7 +828,7 @@ function oneOfValues(...args) {
|
|
|
826
828
|
* @returns Predicate narrowing to a readonly record with guarded key/value types.
|
|
827
829
|
*/
|
|
828
830
|
function recordOf(keyFunction, valueFunction) {
|
|
829
|
-
return define((input) => isPlainObject(input) &&
|
|
831
|
+
return define((input) => isPlainObject(input) && hasOwnEnumerableEntries(input, keyFunction, valueFunction));
|
|
830
832
|
}
|
|
831
833
|
//#endregion
|
|
832
834
|
//#region src/core/combinators/set.ts
|
|
@@ -964,7 +966,7 @@ function typedStruct() {
|
|
|
964
966
|
* @returns Predicate that narrows to a readonly tuple of guarded element types.
|
|
965
967
|
*/
|
|
966
968
|
function tupleOf(...guards) {
|
|
967
|
-
return define((input) => Array.isArray(input) &&
|
|
969
|
+
return define((input) => Array.isArray(input) && hasTupleValues(input, guards));
|
|
968
970
|
}
|
|
969
971
|
//#endregion
|
|
970
972
|
//#region src/utils/to-boolean-predicates.ts
|
package/dist/index.mjs
CHANGED
|
@@ -546,6 +546,15 @@ const everyKeyValueEntry = (entries, predicate) => {
|
|
|
546
546
|
for (const [key, value] of entries) if (!predicate(key, value)) return false;
|
|
547
547
|
return true;
|
|
548
548
|
};
|
|
549
|
+
const hasTupleValues = (values, predicates) => {
|
|
550
|
+
if (values.length !== predicates.length) return false;
|
|
551
|
+
for (let index = 0; index < predicates.length; index += 1) {
|
|
552
|
+
const predicate = predicates[index];
|
|
553
|
+
if (!predicate(values[index])) return false;
|
|
554
|
+
}
|
|
555
|
+
return true;
|
|
556
|
+
};
|
|
557
|
+
const hasOwnEnumerableEntries = (values, keyPredicate, valuePredicate) => everyIterableValue(Object.keys(values), (key) => keyPredicate(key) && valuePredicate(values[key]));
|
|
549
558
|
/**
|
|
550
559
|
* Checks whether every array element satisfies the provided predicate.
|
|
551
560
|
*
|
|
@@ -574,14 +583,7 @@ const everyBrandedArrayValue = (values, predicate) => {
|
|
|
574
583
|
* @param predicates Predicates aligned to each tuple index.
|
|
575
584
|
* @returns Whether lengths match and each index passes.
|
|
576
585
|
*/
|
|
577
|
-
const everyTupleValue = (values, predicates) =>
|
|
578
|
-
if (values.length !== predicates.length) return false;
|
|
579
|
-
for (let index = 0; index < predicates.length; index += 1) {
|
|
580
|
-
const predicate = predicates[index];
|
|
581
|
-
if (!predicate(values[index])) return false;
|
|
582
|
-
}
|
|
583
|
-
return true;
|
|
584
|
-
};
|
|
586
|
+
const everyTupleValue = (values, predicates) => hasTupleValues(values, predicates);
|
|
585
587
|
/**
|
|
586
588
|
* Checks whether every set value satisfies the provided predicate.
|
|
587
589
|
*
|
|
@@ -624,7 +626,7 @@ const everyBrandedMapEntry = (values, keyPredicate, valuePredicate) => everyKeyV
|
|
|
624
626
|
* @param valuePredicate Predicate applied to each corresponding value.
|
|
625
627
|
* @returns Whether all enumerable entries satisfy their predicates.
|
|
626
628
|
*/
|
|
627
|
-
const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) =>
|
|
629
|
+
const everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => hasOwnEnumerableEntries(values, keyPredicate, valuePredicate);
|
|
628
630
|
//#endregion
|
|
629
631
|
//#region src/core/combinators/array.ts
|
|
630
632
|
/**
|
|
@@ -825,7 +827,7 @@ function oneOfValues(...args) {
|
|
|
825
827
|
* @returns Predicate narrowing to a readonly record with guarded key/value types.
|
|
826
828
|
*/
|
|
827
829
|
function recordOf(keyFunction, valueFunction) {
|
|
828
|
-
return define((input) => isPlainObject(input) &&
|
|
830
|
+
return define((input) => isPlainObject(input) && hasOwnEnumerableEntries(input, keyFunction, valueFunction));
|
|
829
831
|
}
|
|
830
832
|
//#endregion
|
|
831
833
|
//#region src/core/combinators/set.ts
|
|
@@ -963,7 +965,7 @@ function typedStruct() {
|
|
|
963
965
|
* @returns Predicate that narrows to a readonly tuple of guarded element types.
|
|
964
966
|
*/
|
|
965
967
|
function tupleOf(...guards) {
|
|
966
|
-
return define((input) => Array.isArray(input) &&
|
|
968
|
+
return define((input) => Array.isArray(input) && hasTupleValues(input, guards));
|
|
967
969
|
}
|
|
968
970
|
//#endregion
|
|
969
971
|
//#region src/utils/to-boolean-predicates.ts
|
package/package.json
CHANGED