@augment-vir/common 6.1.2 → 6.1.4

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.
@@ -45,6 +45,9 @@ export declare function matchesObjectShape<MatchThisGeneric extends object>(test
45
45
  export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
46
46
  [Prop in keyof BaseObject]: BaseObject[Prop] extends ReadonlyArray<any> ? AtLeastOneEntryArray<BaseObject[Prop]> : BaseObject[Prop] extends object ? ObjectWithAtLeastSingleEntryArrays<BaseObject[Prop]> : BaseObject[Prop];
47
47
  };
48
+ export type NestedBoolean<MatchObject extends object> = Partial<{
49
+ [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean;
50
+ }>;
48
51
  /**
49
52
  * Asserts that the first input, testThisOne, matches the object shape of the second input,
50
53
  * compareToThisOne. Does not compare exact values of properties, only types.
@@ -58,7 +61,7 @@ export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
58
61
  * that exists. If more array values are present, they will be considered other possible types for
59
62
  * entries in that array.
60
63
  */
61
- 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;
64
+ export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): asserts testThisOne is MatchThisGeneric;
62
65
  export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;
63
66
  export {};
64
67
  //# sourceMappingURL=object.d.ts.map
@@ -209,6 +209,7 @@ function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps
209
209
  }
210
210
  }
211
211
  matchKeys.forEach((key) => {
212
+ var _a;
212
213
  if (!typedHasProperty(testThisOne, key)) {
213
214
  throw new Error(`test object does not have key "${String(key)}" from expected shape.`);
214
215
  }
@@ -218,12 +219,12 @@ function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExtraProps
218
219
  const testValue = testThisOne[key];
219
220
  const shouldMatch = compareToThisOne[key];
220
221
  if (!noCheckInnerValueOfTheseKeys[key]) {
221
- compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps);
222
+ compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps, (_a = noCheckInnerValueOfTheseKeys[key]) !== null && _a !== void 0 ? _a : {});
222
223
  }
223
224
  });
224
225
  }
225
226
  exports.assertMatchesObjectShape = assertMatchesObjectShape;
226
- function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) {
227
+ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys) {
227
228
  var _a;
228
229
  const testType = typeof testValue;
229
230
  const shouldMatchType = typeof matchValue;
@@ -252,7 +253,7 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
252
253
  const errors = matchValue
253
254
  .map((matchValue) => {
254
255
  try {
255
- compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps);
256
+ compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys);
256
257
  return undefined;
257
258
  }
258
259
  catch (error) {
@@ -266,7 +267,7 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
266
267
  });
267
268
  }
268
269
  else if (isObject(matchValue)) {
269
- assertMatchesObjectShape(testValue, matchValue, allowExtraProps);
270
+ assertMatchesObjectShape(testValue, matchValue, allowExtraProps, noCheckInnerValueOfTheseKeys);
270
271
  }
271
272
  }
272
273
  function typedObjectFromEntries(entries) {
@@ -45,6 +45,9 @@ export declare function matchesObjectShape<MatchThisGeneric extends object>(test
45
45
  export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
46
46
  [Prop in keyof BaseObject]: BaseObject[Prop] extends ReadonlyArray<any> ? AtLeastOneEntryArray<BaseObject[Prop]> : BaseObject[Prop] extends object ? ObjectWithAtLeastSingleEntryArrays<BaseObject[Prop]> : BaseObject[Prop];
47
47
  };
48
+ export type NestedBoolean<MatchObject extends object> = Partial<{
49
+ [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean;
50
+ }>;
48
51
  /**
49
52
  * Asserts that the first input, testThisOne, matches the object shape of the second input,
50
53
  * compareToThisOne. Does not compare exact values of properties, only types.
@@ -58,7 +61,7 @@ export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
58
61
  * that exists. If more array values are present, they will be considered other possible types for
59
62
  * entries in that array.
60
63
  */
61
- 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;
64
+ export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): asserts testThisOne is MatchThisGeneric;
62
65
  export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;
63
66
  export {};
64
67
  //# sourceMappingURL=object.d.ts.map
@@ -190,6 +190,7 @@ export function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExt
190
190
  }
191
191
  }
192
192
  matchKeys.forEach((key) => {
193
+ var _a;
193
194
  if (!typedHasProperty(testThisOne, key)) {
194
195
  throw new Error(`test object does not have key "${String(key)}" from expected shape.`);
195
196
  }
@@ -199,11 +200,11 @@ export function assertMatchesObjectShape(testThisOne, compareToThisOne, allowExt
199
200
  const testValue = testThisOne[key];
200
201
  const shouldMatch = compareToThisOne[key];
201
202
  if (!noCheckInnerValueOfTheseKeys[key]) {
202
- compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps);
203
+ compareInnerValue(testValue, shouldMatch, throwKeyError, allowExtraProps, (_a = noCheckInnerValueOfTheseKeys[key]) !== null && _a !== void 0 ? _a : {});
203
204
  }
204
205
  });
205
206
  }
206
- function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps) {
207
+ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys) {
207
208
  var _a;
208
209
  const testType = typeof testValue;
209
210
  const shouldMatchType = typeof matchValue;
@@ -232,7 +233,7 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
232
233
  const errors = matchValue
233
234
  .map((matchValue) => {
234
235
  try {
235
- compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps);
236
+ compareInnerValue(testValueEntry, matchValue, throwKeyError, allowExtraProps, noCheckInnerValueOfTheseKeys);
236
237
  return undefined;
237
238
  }
238
239
  catch (error) {
@@ -246,7 +247,7 @@ function compareInnerValue(testValue, matchValue, throwKeyError, allowExtraProps
246
247
  });
247
248
  }
248
249
  else if (isObject(matchValue)) {
249
- assertMatchesObjectShape(testValue, matchValue, allowExtraProps);
250
+ assertMatchesObjectShape(testValue, matchValue, allowExtraProps, noCheckInnerValueOfTheseKeys);
250
251
  }
251
252
  }
252
253
  export function typedObjectFromEntries(entries) {
@@ -45,6 +45,9 @@ export declare function matchesObjectShape<MatchThisGeneric extends object>(test
45
45
  export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
46
46
  [Prop in keyof BaseObject]: BaseObject[Prop] extends ReadonlyArray<any> ? AtLeastOneEntryArray<BaseObject[Prop]> : BaseObject[Prop] extends object ? ObjectWithAtLeastSingleEntryArrays<BaseObject[Prop]> : BaseObject[Prop];
47
47
  };
48
+ export type NestedBoolean<MatchObject extends object> = Partial<{
49
+ [Prop in keyof MatchObject]: MatchObject[Prop] extends object ? NestedBoolean<MatchObject[Prop]> | boolean : boolean;
50
+ }>;
48
51
  /**
49
52
  * Asserts that the first input, testThisOne, matches the object shape of the second input,
50
53
  * compareToThisOne. Does not compare exact values of properties, only types.
@@ -58,7 +61,7 @@ export type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
58
61
  * that exists. If more array values are present, they will be considered other possible types for
59
62
  * entries in that array.
60
63
  */
61
- 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;
64
+ export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, noCheckInnerValueOfTheseKeys?: NestedBoolean<typeof compareToThisOne>): asserts testThisOne is MatchThisGeneric;
62
65
  export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;
63
66
  export {};
64
67
  //# sourceMappingURL=object.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "6.1.2",
3
+ "version": "6.1.4",
4
4
  "homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
5
5
  "bugs": {
6
6
  "url": "https://github.com/electrovir/augment-vir/issues"