@augment-vir/common
Advanced tools
@@ -48,2 +48,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
| }; | ||
| type NestedBoolean<MatchObject extends object> = Partial<{ | ||
| [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean; | ||
| }>; | ||
| /** | ||
@@ -62,5 +65,5 @@ * Asserts that the first input, testThisOne, matches the object shape of the second input, | ||
| */ | ||
| 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 assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): 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 |
@@ -212,2 +212,3 @@ "use strict"; | ||
| matchKeys.forEach((key) => { | ||
| var _a; | ||
| if (!typedHasProperty(testThisOne, key)) { | ||
@@ -222,3 +223,3 @@ throw new Error(`test object does not have key "${String(key)}" from expected shape.`); | ||
| if (!noCheckInnerValueOfTheseKeys[key]) { | ||
| compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps); | ||
| compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps, (_a = noCheckInnerValueOfTheseKeys[key]) !== null && _a !== void 0 ? _a : {}); | ||
| } | ||
@@ -228,3 +229,3 @@ }); | ||
| exports.assertMatchesObjectShape = assertMatchesObjectShape; | ||
| function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) { | ||
| function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys) { | ||
| var _a; | ||
@@ -258,3 +259,3 @@ const testType = typeof testValue; | ||
| try { | ||
| compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps); | ||
| compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys); | ||
| return undefined; | ||
@@ -273,3 +274,3 @@ } | ||
| else if (isObject(matchValue)) { | ||
| assertMatchesObjectShape(testValue, matchValue, allowExtraProps); | ||
| assertMatchesObjectShape(testValue, matchValue, allowExtraProps, noCheckInnerValueOfTheseKeys); | ||
| } | ||
@@ -276,0 +277,0 @@ } |
@@ -48,2 +48,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
| }; | ||
| type NestedBoolean<MatchObject extends object> = Partial<{ | ||
| [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean; | ||
| }>; | ||
| /** | ||
@@ -62,5 +65,5 @@ * Asserts that the first input, testThisOne, matches the object shape of the second input, | ||
| */ | ||
| 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 assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): 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 |
@@ -193,2 +193,3 @@ import { extractErrorMessage } from './error'; | ||
| matchKeys.forEach((key) => { | ||
| var _a; | ||
| if (!typedHasProperty(testThisOne, key)) { | ||
@@ -203,7 +204,7 @@ throw new Error(`test object does not have key "${String(key)}" from expected shape.`); | ||
| if (!noCheckInnerValueOfTheseKeys[key]) { | ||
| compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps); | ||
| compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps, (_a = noCheckInnerValueOfTheseKeys[key]) !== null && _a !== void 0 ? _a : {}); | ||
| } | ||
| }); | ||
| } | ||
| function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) { | ||
| function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys) { | ||
| var _a; | ||
@@ -237,3 +238,3 @@ const testType = typeof testValue; | ||
| try { | ||
| compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps); | ||
| compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys); | ||
| return undefined; | ||
@@ -252,3 +253,3 @@ } | ||
| else if (isObject(matchValue)) { | ||
| assertMatchesObjectShape(testValue, matchValue, allowExtraProps); | ||
| assertMatchesObjectShape(testValue, matchValue, allowExtraProps, noCheckInnerValueOfTheseKeys); | ||
| } | ||
@@ -255,0 +256,0 @@ } |
@@ -48,2 +48,5 @@ import { AtLeastOneEntryArray } from './array'; | ||
| }; | ||
| type NestedBoolean<MatchObject extends object> = Partial<{ | ||
| [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean; | ||
| }>; | ||
| /** | ||
@@ -62,5 +65,5 @@ * Asserts that the first input, testThisOne, matches the object shape of the second input, | ||
| */ | ||
| 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 assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): 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 |
+1
-1
| { | ||
| "name": "@augment-vir/common", | ||
| "version": "6.1.2", | ||
| "version": "6.1.3", | ||
| "homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common", | ||
@@ -5,0 +5,0 @@ "bugs": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
141352
0.62%2867
0.39%6
20%