@augment-vir/common
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -61,5 +61,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
*/ | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean): asserts testThisOne is MatchThisGeneric; | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: Partial<Record<keyof typeof compareToThisOne, boolean>>): asserts testThisOne is MatchThisGeneric; | ||
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>; | ||
export {}; | ||
//# sourceMappingURL=object.d.ts.map |
@@ -202,3 +202,3 @@ "use strict"; | ||
*/ | ||
function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps = false) { | ||
function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps = false, noCheckInnerValueOfTheseKeys = {}) { | ||
const testKeys = getObjectTypedKeys(testThisOne); | ||
@@ -221,7 +221,9 @@ const matchKeys = new Set(getObjectTypedKeys(compareToThisOne)); | ||
const shouldMatch = compareToThisOne[key]; | ||
compareInnerValue(testValue, shouldMatch, throwKeyError); | ||
if (!noCheckInnerValueOfTheseKeys[key]) { | ||
compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps); | ||
} | ||
}); | ||
} | ||
exports.assertMatchesObjectShape = assertMatchesObjectShape; | ||
function compareInnerValue(testValue, matchValue, throwKeyError) { | ||
function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) { | ||
var _a; | ||
@@ -255,3 +257,3 @@ const testType = typeof testValue; | ||
try { | ||
compareInnerValue(testValueEntry, matchValue, throwKeyError); | ||
compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps); | ||
return undefined; | ||
@@ -270,3 +272,3 @@ } | ||
else if (isObject(matchValue)) { | ||
assertMatchesObjectShape(testValue, matchValue); | ||
assertMatchesObjectShape(testValue, matchValue, allowExtraProps); | ||
} | ||
@@ -273,0 +275,0 @@ } |
@@ -61,5 +61,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
*/ | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean): asserts testThisOne is MatchThisGeneric; | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: Partial<Record<keyof typeof compareToThisOne, boolean>>): asserts testThisOne is MatchThisGeneric; | ||
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>; | ||
export {}; | ||
//# sourceMappingURL=object.d.ts.map |
@@ -183,3 +183,3 @@ import { extractErrorMessage } from './error'; | ||
*/ | ||
export function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps = false) { | ||
export function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps = false, noCheckInnerValueOfTheseKeys = {}) { | ||
const testKeys = getObjectTypedKeys(testThisOne); | ||
@@ -202,6 +202,8 @@ const matchKeys = new Set(getObjectTypedKeys(compareToThisOne)); | ||
const shouldMatch = compareToThisOne[key]; | ||
compareInnerValue(testValue, shouldMatch, throwKeyError); | ||
if (!noCheckInnerValueOfTheseKeys[key]) { | ||
compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps); | ||
} | ||
}); | ||
} | ||
function compareInnerValue(testValue, matchValue, throwKeyError) { | ||
function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) { | ||
var _a; | ||
@@ -235,3 +237,3 @@ const testType = typeof testValue; | ||
try { | ||
compareInnerValue(testValueEntry, matchValue, throwKeyError); | ||
compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps); | ||
return undefined; | ||
@@ -250,3 +252,3 @@ } | ||
else if (isObject(matchValue)) { | ||
assertMatchesObjectShape(testValue, matchValue); | ||
assertMatchesObjectShape(testValue, matchValue, allowExtraProps); | ||
} | ||
@@ -253,0 +255,0 @@ } |
@@ -61,5 +61,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
*/ | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean): asserts testThisOne is MatchThisGeneric; | ||
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: Partial<Record<keyof typeof compareToThisOne, boolean>>): asserts testThisOne is MatchThisGeneric; | ||
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>; | ||
export {}; | ||
//# sourceMappingURL=object.d.ts.map |
{ | ||
"name": "@augment-vir/common", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common", | ||
@@ -5,0 +5,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140480
2856
66312