hein 2.0.0-alpha.1 → 2.0.0-alpha.2

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.
@@ -1,4 +1,4 @@
1
- import { Constructor, ErrorPredicate, ValueType, notThrows, throws } from "./throws-BlzO4xvg.js";
1
+ import "hein-assertion-utils";
2
2
 
3
3
  //#region src/assert/deep-equal.d.ts
4
4
  declare const deepEqual: <T>(actual: T, expected: T, partialOrMessage?: string | boolean, message?: string) => true | void, notDeepEqual: <T>(actual: T, expected: T, partialOrMessage?: string | boolean, message?: string) => true | void;
@@ -112,6 +112,12 @@ interface Includes {
112
112
  }
113
113
  declare const includes: Includes, notIncludes: Includes;
114
114
  //#endregion
115
+ //#region src/utils/process-error.d.ts
116
+ interface Constructor<T = any> {
117
+ new (...args: any[]): T;
118
+ }
119
+ type ErrorPredicate = (error: Error) => boolean;
120
+ //#endregion
115
121
  //#region src/assert/instance-of.d.ts
116
122
  interface InstanceOf {
117
123
  /**
@@ -153,6 +159,9 @@ interface IsEmpty {
153
159
  }
154
160
  declare const isEmpty: IsEmpty, notIsEmpty: IsEmpty;
155
161
  //#endregion
162
+ //#region src/utils/get-type.d.ts
163
+ type ValueType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'null' | 'NaN' | 'array';
164
+ //#endregion
156
165
  //#region src/assert/is-type.d.ts
157
166
  interface IsType {
158
167
  /**
@@ -309,6 +318,38 @@ interface Rejects {
309
318
  }
310
319
  declare const rejects: Rejects, notRejects: Rejects;
311
320
  //#endregion
321
+ //#region src/assert/throws.d.ts
322
+ type ThrowsCallback = () => unknown;
323
+ interface Throw {
324
+ /**
325
+ * check if function throws an error
326
+ * @param callback
327
+ * @example throws(() => { throw new Error('foo'); });
328
+ * @example throws(() => { throw new TypeError('foo'); }, TypeError);
329
+ */
330
+ (callback: ThrowsCallback, message?: string): void;
331
+ /**
332
+ * check if function throws an error matching the constructor
333
+ * @param callback
334
+ * @example throws(() => { throw new TypeError('foo'); }, TypeError);
335
+ */
336
+ (callback: ThrowsCallback, expectedError: Constructor, message?: string): void;
337
+ /**
338
+ * check if function throws an error matching the regex
339
+ * @param callback
340
+ * @example throws(() => { throw new Error('foo'); });
341
+ * @example throws(() => { throw new TypeError('foo'); }, /foo/);
342
+ */
343
+ (callback: ThrowsCallback, expectedError: RegExp, message?: string): void;
344
+ /**
345
+ * check if function throws an error matching the predicate function
346
+ * @param callback
347
+ * @example throws(() => { throw new TypeError('foo'); }, (error) => error.message === 'foo');
348
+ */
349
+ (callback: ThrowsCallback, expectedError: ErrorPredicate, message?: string): void;
350
+ }
351
+ declare const throws: Throw, notThrows: Throw;
352
+ //#endregion
312
353
  //#region src/assert/deep-has-property.d.ts
313
354
  interface DeepHasProperty {
314
355
  /**
@@ -474,5 +515,5 @@ declare namespace assert_d_exports {
474
515
  }
475
516
  declare const assert: () => never;
476
517
  //#endregion
477
- export { assert, assert_d_exports, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, rejects, roundTo, startsWith };
478
- //# sourceMappingURL=assert-CsN7srt-.d.ts.map
518
+ export { Constructor, ErrorPredicate, ThrowsCallback, ValueType, assert, assert_d_exports, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws };
519
+ //# sourceMappingURL=assert-CJsbhtgi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-CJsbhtgi.d.ts","names":[],"sources":["../src/assert/deep-equal.ts","../src/assert/equal.ts","../src/assert/greater-than.ts","../src/assert/greater-than-equal.ts","../src/assert/has-property.ts","../src/assert/has-size.ts","../src/assert/includes.ts","../src/utils/process-error.ts","../src/assert/instance-of.ts","../src/assert/is-empty.ts","../src/utils/get-type.ts","../src/assert/is-type.ts","../src/assert/less-than.ts","../src/assert/less-than-equal.ts","../src/assert/match.ts","../src/assert/rejects.ts","../src/assert/throws.ts","../src/assert/deep-has-property.ts","../src/assert/starts-with.ts","../src/assert/ends-with.ts","../src/assert/is-before.ts","../src/assert/is-after.ts","../src/assert/is-between.ts","../src/assert/in-ballpark.ts","../src/assert/round-to.ts","../src/assert/has-members.ts","../src/assert/has-keys.ts","../src/assert.ts"],"sourcesContent":[],"mappings":";;;cAIc,uBAOM,aAAa,oGAAb,aAAa;;;UCTvB,KAAA;;;;EDEI,CAAA,CAAA,CAAA,CAAA,MAAA,ECEE,CDKgF,EAAA,QAAA,ECLnE,CDKmE,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;AAA5E,cCFN,KDEM,ECFD,KDEC,EAAA,QAAA,ECFS,KDET;;;UERV,WAAA;;;;EFCI,CAAA,UAAA,MAOkF,GAAA,MAAA,GEJ/D,IFI+D,CAAA,CAAA,MAAA,EEJjD,CFIiD,EAAA,QAAA,EEJpC,CFIoC,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;AAA5E,cEDN,WFCM,EEDK,WFCL,EAAA,cAAA,EEDqB,WFCrB;;;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EAAA,IAAA;;AAAc,cwBEpB,OxBFoB,EwBEb,OxBFa,EAAA,UAAA,EwBED,OxBFC;;;UyBRxB,iBAAA;;;;AzBCV;;;MAOiC,CAAA,EAAA,OAAA;;;;;;;;ECTvB,OAAA,CAAK,EAAA,OAAA;EAAA;;;;AAOf;;;MAA6B,CAAA,EAAA,OAAA;EAgB3B;;;;;;;SClB+B,CAAA,EAAA,OAAA;;UuB8BvB,UAAA,CvB9BkD;EAAC;AAG7D;;;;;;cuBmCgB,eAAe,eAAe;;cAGhC,YAAU,2BAAe;;;UC7C7B,OAAA;;;;A1BCV;;;;a0BOe,M1BAK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,UAAA,M0BAgC,C1BAhC,CAAA,CAAA,MAAA,E0BA2C,C1BA3C,EAAA,IAAA,E0BAoD,C1BApD,EAAA,G0BA0D,C1BA1D,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;MAAa,U0BCf,G1BDe,C0BCX,C1BDW,EAAA,GAAA,CAAA,CAAA,CAAA,MAAA,E0BCM,C1BDN,EAAA,IAAA,E0BCe,C1BDf,EAAA,G0BCqB,C1BDrB,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;AAPR,c0BWX,O1BXW,E0BWJ,O1BXI,EAAA,UAAA,E0BWQ,O1BXR;AAAA;;;ACKJ,c0BiBR,M1BjBQ,EAAA,GAAA,GAAA,KAAA"}
@@ -1,6 +1,3 @@
1
- import { Constructor, ErrorPredicate, ValueType, notThrows, throws } from "./throws-CYLYG7gu.cjs";
2
-
3
- //#region rolldown:runtime
4
1
  //#endregion
5
2
  //#region src/assert/deep-equal.d.ts
6
3
  declare const deepEqual: <T>(actual: T, expected: T, partialOrMessage?: string | boolean, message?: string) => true | void, notDeepEqual: <T>(actual: T, expected: T, partialOrMessage?: string | boolean, message?: string) => true | void;
@@ -114,6 +111,12 @@ interface Includes {
114
111
  }
115
112
  declare const includes: Includes, notIncludes: Includes;
116
113
  //#endregion
114
+ //#region src/utils/process-error.d.ts
115
+ interface Constructor<T = any> {
116
+ new (...args: any[]): T;
117
+ }
118
+ type ErrorPredicate = (error: Error) => boolean;
119
+ //#endregion
117
120
  //#region src/assert/instance-of.d.ts
118
121
  interface InstanceOf {
119
122
  /**
@@ -155,6 +158,9 @@ interface IsEmpty {
155
158
  }
156
159
  declare const isEmpty: IsEmpty, notIsEmpty: IsEmpty;
157
160
  //#endregion
161
+ //#region src/utils/get-type.d.ts
162
+ type ValueType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'null' | 'NaN' | 'array';
163
+ //#endregion
158
164
  //#region src/assert/is-type.d.ts
159
165
  interface IsType {
160
166
  /**
@@ -311,6 +317,38 @@ interface Rejects {
311
317
  }
312
318
  declare const rejects: Rejects, notRejects: Rejects;
313
319
  //#endregion
320
+ //#region src/assert/throws.d.ts
321
+ type ThrowsCallback = () => unknown;
322
+ interface Throw {
323
+ /**
324
+ * check if function throws an error
325
+ * @param callback
326
+ * @example throws(() => { throw new Error('foo'); });
327
+ * @example throws(() => { throw new TypeError('foo'); }, TypeError);
328
+ */
329
+ (callback: ThrowsCallback, message?: string): void;
330
+ /**
331
+ * check if function throws an error matching the constructor
332
+ * @param callback
333
+ * @example throws(() => { throw new TypeError('foo'); }, TypeError);
334
+ */
335
+ (callback: ThrowsCallback, expectedError: Constructor, message?: string): void;
336
+ /**
337
+ * check if function throws an error matching the regex
338
+ * @param callback
339
+ * @example throws(() => { throw new Error('foo'); });
340
+ * @example throws(() => { throw new TypeError('foo'); }, /foo/);
341
+ */
342
+ (callback: ThrowsCallback, expectedError: RegExp, message?: string): void;
343
+ /**
344
+ * check if function throws an error matching the predicate function
345
+ * @param callback
346
+ * @example throws(() => { throw new TypeError('foo'); }, (error) => error.message === 'foo');
347
+ */
348
+ (callback: ThrowsCallback, expectedError: ErrorPredicate, message?: string): void;
349
+ }
350
+ declare const throws: Throw, notThrows: Throw;
351
+ //#endregion
314
352
  //#region src/assert/deep-has-property.d.ts
315
353
  interface DeepHasProperty {
316
354
  /**
@@ -476,5 +514,5 @@ declare namespace assert_d_exports {
476
514
  }
477
515
  declare const assert: () => never;
478
516
  //#endregion
479
- export { assert, assert_d_exports, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, rejects, roundTo, startsWith };
480
- //# sourceMappingURL=assert-ChQPKP5C.d.cts.map
517
+ export { Constructor, ErrorPredicate, ThrowsCallback, ValueType, assert, assert_d_exports, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws };
518
+ //# sourceMappingURL=assert-itrfuDRd.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-itrfuDRd.d.cts","names":[],"sources":["../src/assert/deep-equal.ts","../src/assert/equal.ts","../src/assert/greater-than.ts","../src/assert/greater-than-equal.ts","../src/assert/has-property.ts","../src/assert/has-size.ts","../src/assert/includes.ts","../src/utils/process-error.ts","../src/assert/instance-of.ts","../src/assert/is-empty.ts","../src/utils/get-type.ts","../src/assert/is-type.ts","../src/assert/less-than.ts","../src/assert/less-than-equal.ts","../src/assert/match.ts","../src/assert/rejects.ts","../src/assert/throws.ts","../src/assert/deep-has-property.ts","../src/assert/starts-with.ts","../src/assert/ends-with.ts","../src/assert/is-before.ts","../src/assert/is-after.ts","../src/assert/is-between.ts","../src/assert/in-ballpark.ts","../src/assert/round-to.ts","../src/assert/has-members.ts","../src/assert/has-keys.ts","../src/assert.ts"],"sourcesContent":[],"mappings":";;cAIc,uBAOM,aAAa,oGAAb,aAAa;;;UCTvB,KAAA;;;;cAIM,aAAa;;cAGf,OAAK,iBAAU;;;UCNnB,WAAA;;;;+BAIuB,cAAc,aAAa;;cAG9C,aAAW,6BAAgB;;;UCP/B,gBAAA;;;;+BAIuB,cAAc,aAAa;;cAG9C,kBAAgB,uCAAqB;;;UCRzC,WAAA;;;;;;;sBAOc,WAAW,aAAa;;;;;;AJLhD;;MAOoB,UAAA,MIMI,CJNJ,CAAA,CAAA,MAAA,EIMe,CJNf,EAAA,QAAA,EIM4B,CJN5B,EAAA,KAAA,EIMsC,CJNtC,CIMwC,CJNxC,CAAA,CAAA,EAAA,IAAA;;AAAA,cISN,WJTM,EISK,WJTL,EAAA,cAAA,EISqB,WJTrB;;;UKRV,OAAA;;;;;;;;;;;;;ALCV;EAOgG,CAAA,MAAA,EKMnF,MLNmF,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;;;;;;;QKatF;;;;;;;EJlBoB,CAAA,GAAA,EIyBpB,GJzBoB,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAGhB;;;;;;;;cIgCA,SAAO,qBAAY;;;UCvCvB,QAAA;;;;;;;;aAQK,kBAAkB;;;;;ANNjC;;;;SAOoB,EAAA,MAAA,EAAA,GAAA,QAAA,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,c0BwBF,M1BxBE,EAAA,GAAA,GAAA,KAAA"}
package/dist/assert.d.cts CHANGED
@@ -1,3 +1,2 @@
1
- import { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, rejects, roundTo, startsWith } from "./assert-ChQPKP5C.cjs";
2
- import { notThrows, throws } from "./throws-CYLYG7gu.cjs";
1
+ import { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws } from "./assert-itrfuDRd.cjs";
3
2
  export { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws };
package/dist/assert.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, rejects, roundTo, startsWith } from "./assert-CsN7srt-.js";
2
- import { notThrows, throws } from "./throws-BlzO4xvg.js";
1
+ import { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws } from "./assert-CJsbhtgi.js";
3
2
  export { assert, deepEqual, deepHasProperty, deepNotHasProperty, endsWith, equal, greaterThan, greaterThanEqual, hasKeys, hasMembers, hasProperty, hasSize, inBallpark, includes, instanceOf, isAfter, isBefore, isBetween, isEmpty, isType, lessThan, lessThanEqual, match, notAfter, notBefore, notBetween, notDeepEqual, notEndsWith, notEqual, notGreaterThan, notGreaterThanEqual, notHasKeys, notHasMembers, notHasProperty, notHasSize, notInBallpark, notIncludes, notInstanceOf, notIsEmpty, notIsType, notLessThan, notLessThanEqual, notMatch, notRejects, notRoundTo, notStartsWith, notThrows, rejects, roundTo, startsWith, throws };
@@ -1,3 +1,457 @@
1
- import "./throws-CYLYG7gu.cjs";
2
- import { ArrayExpect, BigIntExpect, BooleanExpect, DateExpect, Expect, FunctionExpect, Loose, MapExpect, NumberExpect, ObjectExpect, PromiseExpect, State, StringExpect, SymbolExpect, ValueExpect } from "./expect.types-CHYPdbCW.cjs";
3
- export { ArrayExpect, BigIntExpect, BooleanExpect, DateExpect, Expect, FunctionExpect, Loose, MapExpect, NumberExpect, ObjectExpect, PromiseExpect, State, StringExpect, SymbolExpect, ValueExpect };
1
+ //#region src/utils/process-error.d.ts
2
+ interface Constructor<T = any> {
3
+ new (...args: any[]): T;
4
+ }
5
+ type ErrorPredicate = (error: Error) => boolean;
6
+ //#endregion
7
+ //#region src/assert/throws.d.ts
8
+ type ThrowsCallback = () => unknown;
9
+ //#endregion
10
+ //#region src/utils/fail.d.ts
11
+ /**
12
+ * Throw an AssertionError
13
+ * @param {string} message - The message to pass to the AssertionError
14
+ */
15
+ declare const fail: (message?: string) => never;
16
+ //#endregion
17
+ //#region src/utils/types.d.ts
18
+ type DeepPartial<T> = { [P in keyof T]?: T[P] | (T[P] extends Array<infer U> ? Array<DeepPartial<U>> : DeepPartial<T[P]>) };
19
+ //#endregion
20
+ //#region src/utils/get-type.d.ts
21
+ type ValueType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'null' | 'NaN' | 'array';
22
+ //#endregion
23
+ //#region src/mixins.d.ts
24
+ interface State<T> {
25
+ inverted?: boolean;
26
+ value?: T;
27
+ getProperty?: (value: T) => any;
28
+ deep?: boolean;
29
+ same?: boolean;
30
+ ordered?: boolean;
31
+ partial?: boolean;
32
+ every?: boolean;
33
+ }
34
+ //#endregion
35
+ //#region src/expect.types.d.ts
36
+ interface ValueExpect<T> {
37
+ to: this;
38
+ be: this;
39
+ a: this;
40
+ an: this;
41
+ not: this;
42
+ and: this;
43
+ have: this;
44
+ in: this;
45
+ of: this;
46
+ /**
47
+ * Use deep equality for object checks
48
+ */
49
+ deep: this;
50
+ /**
51
+ * check for deep equality
52
+ */
53
+ eql(value: T, message?: string): this;
54
+ partially: ValueExpect<DeepPartial<T>>;
55
+ /**
56
+ * check for === equality, NaN is considered equal to NaN
57
+ */
58
+ equal(value: T, message?: string): this;
59
+ /**
60
+ * check for === equality, NaN is considered equal to NaN
61
+ */
62
+ eq(value: T, message?: string): this;
63
+ /**
64
+ * check if value has a property
65
+ * @param property a property in the object. When combined with .deep. can be a path like 'a.b.c'
66
+ * @example expect({a: {b: {c: 1}}}).to.have.property('a.b.c');
67
+ * @example expect({a: {b: {c: 1}}}).to.have.deep.property('[0].a.b.c');
68
+ */
69
+ property<K extends keyof T>(property: K): this;
70
+ /**
71
+ * check if value has a property
72
+ * @param property a property in the object. When combined with .deep. can be a path like 'a.b.c'
73
+ * @example expect({a: {b: {c: 1}}}).to.have.property('a.b.c');
74
+ * @example expect({a: {b: {c: 1}}}).to.have.deep.property('[0].a.b.c');
75
+ */
76
+ property(property: string): this;
77
+ /**
78
+ * check if value has a property
79
+ * @param property a property in the object. When combined with .deep. can be a path like 'a.b.c'
80
+ * @param value
81
+ * @example expect({a: {b: {c: 1}}}).to.have.property('a.b.c');
82
+ * @example expect({a: {b: {c: 1}}}).to.have.deep.property('[0].a.b.c');
83
+ */
84
+ property<K extends keyof T>(property: K, value?: any): this;
85
+ /**
86
+ * check if value has a property
87
+ * @param property a property in the object. When combined with .deep. can be a path like 'a.b.c'
88
+ * @param value
89
+ * @example expect({a: {b: {c: 1}}}).to.have.property('a.b.c');
90
+ * @example expect({a: {b: {c: 1}}}).to.have.deep.property('[0].a.b.c');
91
+ */
92
+ property(property: string, value?: any): this;
93
+ /**
94
+ * check if instance of value
95
+ * @param constructor - The constructor function to check against
96
+ */
97
+ instanceOf(constructor: Constructor): this;
98
+ /**
99
+ * check if value is null
100
+ */
101
+ null(): this;
102
+ /**
103
+ * check if value is undefined
104
+ */
105
+ undefined(): this;
106
+ /**
107
+ * check if value is of certain type
108
+ */
109
+ type(type: ValueType): this;
110
+ }
111
+ type ArrayType<T, DT = never> = T extends (infer U)[] ? U : DT;
112
+ interface ArrayExpect<T> extends ValueExpect<T>, ObjectExpect<T> {
113
+ length: NumberExpect<number> & this;
114
+ array(): this;
115
+ every: GetExpectType<ArrayType<T>>;
116
+ /**
117
+ * check if array includes element(s)
118
+ */
119
+ include(...elements: ArrayType<T>[]): this;
120
+ /**
121
+ * check if array includes element(s)
122
+ */
123
+ contain(...elements: ArrayType<T>[]): this;
124
+ /**
125
+ * check for array length
126
+ */
127
+ lengthOf(length: number, message?: string): this;
128
+ /**
129
+ * check that the members in second array are present in the first one
130
+ */
131
+ members(value: ArrayType<T, any>[], message?: string): this;
132
+ same: ArrayExpect<T>;
133
+ ordered: ArrayExpect<T>;
134
+ /**
135
+ * Use partial matching for objects
136
+ * @example
137
+ * expect({ a: 1, b: 2 }).to.partially.eql({ a: 1 });
138
+ */
139
+ partially: ArrayExpect<DeepPartial<T>>;
140
+ /**
141
+ * check if value is an array
142
+ */
143
+ array(): this;
144
+ }
145
+ interface BigIntExpect<T = bigint> extends NumberExpect<T> {
146
+ /**
147
+ * check if value is a bigint
148
+ */
149
+ bigint(): this;
150
+ }
151
+ interface BooleanExpect<T = boolean> extends ValueExpect<T> {
152
+ /**
153
+ * check if value is a boolean
154
+ */
155
+ boolean(): this;
156
+ /**
157
+ * check if value is true
158
+ */
159
+ true(): this;
160
+ /**
161
+ * check if value is false
162
+ */
163
+ false(): this;
164
+ }
165
+ interface DateExpect<T = Date> extends ValueExpect<T>, ObjectExpect<T> {
166
+ /**
167
+ * check if date is after other date
168
+ * @param date
169
+ */
170
+ after(date: Date): this;
171
+ /**
172
+ * check if date is before other date
173
+ * @param date
174
+ */
175
+ before(date: Date): this;
176
+ /**
177
+ * check if date is between other dates
178
+ * @param start
179
+ * @param end
180
+ */
181
+ between(start: Date, end: Date, inclusive?: boolean): this;
182
+ /**
183
+ * check if actual is greater than or equal to expected
184
+ */
185
+ greaterThanOrEqual(value: T): this;
186
+ /**
187
+ * check if actual is greater than or equal to expected
188
+ */
189
+ gte(value: T): this;
190
+ /**
191
+ * check if actual is greater than or equal to expected
192
+ */
193
+ atLeast(value: T): this;
194
+ /**
195
+ * check if actual is greater than expected
196
+ */
197
+ greaterThan(value: T): this;
198
+ /**
199
+ * check if actual is greater than expected
200
+ */
201
+ gt(value: T): this;
202
+ /**
203
+ * check if actual is greater than expected
204
+ */
205
+ above(value: T): this;
206
+ /**
207
+ * check if value is an instance of Date
208
+ */
209
+ Date(): this;
210
+ /**
211
+ * check if actual is less than or equal to expected
212
+ */
213
+ lessThanOrEqual(value: T): this;
214
+ /**
215
+ * check if actual is less than or equal to expected
216
+ */
217
+ lte(value: T): this;
218
+ /**
219
+ * check if actual is less than or equal to expected
220
+ */
221
+ atMost(value: T): this;
222
+ /**
223
+ * check if actual is less than expected
224
+ */
225
+ lessThan(value: T): this;
226
+ /**
227
+ * check if actual is less than expected
228
+ */
229
+ lt(value: T): this;
230
+ /**
231
+ * check if actual is less than expected
232
+ */
233
+ below(value: T): this;
234
+ }
235
+ interface FunctionExpect<T> extends ValueExpect<T> {
236
+ /**
237
+ * check if function throws
238
+ * @param message
239
+ */
240
+ throw(message?: string): this;
241
+ throw(matcher: RegExp | Constructor<Error> | ErrorPredicate, message?: string): this;
242
+ /**
243
+ * check if value is a function
244
+ */
245
+ function(): this;
246
+ }
247
+ interface NumberExpect<T = number> extends ValueExpect<T> {
248
+ /**
249
+ * check if number close enough (default 10%)
250
+ * @param ballpark
251
+ * @param [multiplier=10] - a number between 0 and 1 (exclusive). 0.1 (default) means 10% difference is allowed.
252
+ */
253
+ ballpark(ballpark: number, multiplier?: number): this;
254
+ /**
255
+ * check if number is between other numbers
256
+ * @param start
257
+ * @param end
258
+ * @param inclusive
259
+ */
260
+ between(start: number, end: number, inclusive?: boolean): this;
261
+ /**
262
+ * check if actual is greater than or equal to expected
263
+ */
264
+ greaterThanOrEqual(value: T): this;
265
+ /**
266
+ * check if actual is greater than or equal to expected
267
+ */
268
+ gte(value: T): this;
269
+ /**
270
+ * check if actual is greater than or equal to expected
271
+ */
272
+ atLeast(value: T): this;
273
+ /**
274
+ * check if actual is greater than expected
275
+ */
276
+ greaterThan(value: T): this;
277
+ /**
278
+ * check if actual is greater than expected
279
+ */
280
+ gt(value: T): this;
281
+ /**
282
+ * check if actual is greater than expected
283
+ */
284
+ above(value: T): this;
285
+ /**
286
+ * check if actual is less than or equal to expected
287
+ */
288
+ lessThanOrEqual(value: T): this;
289
+ /**
290
+ * check if actual is less than or equal to expected
291
+ */
292
+ lte(value: T): this;
293
+ /**
294
+ * check if actual is less than or equal to expected
295
+ */
296
+ atMost(value: T): this;
297
+ /**
298
+ * check if actual is less than expected
299
+ */
300
+ lessThan(value: T): this;
301
+ /**
302
+ * check if actual is less than expected
303
+ */
304
+ lt(value: T): this;
305
+ /**
306
+ * check if actual is less than expected
307
+ */
308
+ below(value: T): this;
309
+ /**
310
+ * check if number close enough (default 10%)
311
+ * @param target
312
+ * @param decimal defaults to 0, can be negative if trying to round down to nearest 10, 100, etc
313
+ */
314
+ roundTo(target: number, decimal?: number): this;
315
+ /**
316
+ * check if value is a number
317
+ */
318
+ number(): this;
319
+ /**
320
+ * check if value is a NaN
321
+ */
322
+ NaN(): this;
323
+ }
324
+ type InferMapKeys<T> = T extends Map<infer K, any> ? K : never;
325
+ interface MapExpect<T> extends ValueExpect<T> {
326
+ size: NumberExpect<number>;
327
+ /**
328
+ * check if Map is empty
329
+ */
330
+ empty(message?: string): this;
331
+ /**
332
+ * check if value is an instance of Map
333
+ */
334
+ Map(): this;
335
+ /**
336
+ * Check if value has keys
337
+ */
338
+ keys<K extends InferMapKeys<T>>(keys: K[] | K): this;
339
+ /**
340
+ * check for Map to have a certain size
341
+ */
342
+ sizeOf(size: number, message?: string): this;
343
+ }
344
+ interface ObjectExpect<T> extends ValueExpect<T> {
345
+ size: NumberExpect<number>;
346
+ /**
347
+ * check if object/array/Map/Set is empty
348
+ */
349
+ empty(message?: string): this;
350
+ /**
351
+ * exclude keys from object to be compared further down the chain
352
+ * @param keys
353
+ */
354
+ excluding<K extends keyof T>(...keys: K[]): ObjectExpect<Omit<T, K>>;
355
+ /**
356
+ * check if value is an instance of Map
357
+ */
358
+ Map(): this;
359
+ /**
360
+ * check if value is an instance of Set
361
+ */
362
+ Set(): this;
363
+ /**
364
+ * check if value is an instance of WeakMap
365
+ */
366
+ WeakMap(): this;
367
+ /**
368
+ * check if value is an instance of WeakSet
369
+ */
370
+ WeakSet(): this;
371
+ /**
372
+ * Check if value has keys
373
+ */
374
+ keys<K extends keyof T>(keys: K[] | K): this;
375
+ /**
376
+ * check for object/array/Map/Set/string to have a certain size
377
+ */
378
+ sizeOf(size: number, message?: string): this;
379
+ /**
380
+ * check if value is a plain object
381
+ */
382
+ object(): this;
383
+ }
384
+ interface PromiseExpect<T> extends ValueExpect<T> {
385
+ /**
386
+ * check if promise rejects
387
+ * @param message
388
+ */
389
+ reject(message?: string): Promise<void>;
390
+ reject(matcher: RegExp | Constructor<Error> | ErrorPredicate): Promise<void>;
391
+ }
392
+ interface StringExpect<T = string> extends ValueExpect<T> {
393
+ /**
394
+ * check if string ends with other string
395
+ * @param start
396
+ * @example endsWith('foo', 'o');
397
+ */
398
+ endWith(end: string): this;
399
+ /**
400
+ * check if string includes substring(s)
401
+ */
402
+ include(...substrings: string[]): this;
403
+ /**
404
+ * check if string includes substring(s)
405
+ */
406
+ contain(...substrings: string[]): this;
407
+ /**
408
+ * check for string to have a certain size
409
+ */
410
+ lengthOf(length: number, message?: string): this;
411
+ /**
412
+ * check if string matches regex
413
+ */
414
+ match(regex: RegExp): this;
415
+ /**
416
+ * check if string starts with other string
417
+ * @param start
418
+ * @example startsWith('foo', 'f');
419
+ */
420
+ startWith(start: string): this;
421
+ /**
422
+ * check if value is a string
423
+ */
424
+ string(): this;
425
+ }
426
+ interface SymbolExpect<T> extends ValueExpect<T> {
427
+ /**
428
+ * check if value is a symbol
429
+ */
430
+ symbol(): this;
431
+ }
432
+ declare const LooseSymbol: unique symbol;
433
+ interface Loose {
434
+ [LooseSymbol]: true;
435
+ }
436
+ type AllExpects<T> = ArrayExpect<T> & BigIntExpect<T> & BooleanExpect<T> & DateExpect<T> & FunctionExpect<T> & NumberExpect<T> & MapExpect<T> & ObjectExpect<T> & PromiseExpect<T> & StringExpect<T> & SymbolExpect<T> & ValueExpect<T>;
437
+ interface Expect {
438
+ <T extends Loose>(actual: T): AllExpects<T>;
439
+ <T extends ThrowsCallback>(actual: T): FunctionExpect<T>;
440
+ <T extends Promise<any>>(actual: T): PromiseExpect<T>;
441
+ <T extends any[]>(actual: T): ArrayExpect<T>;
442
+ <T extends Date>(actual: T): DateExpect<T>;
443
+ <T extends Map<any, any>>(actual: T): MapExpect<T>;
444
+ <T extends Record<string, any>>(actual: T): ObjectExpect<T>;
445
+ <T extends number>(actual: T): NumberExpect;
446
+ <T extends bigint>(actual: T): BigIntExpect;
447
+ <T extends boolean>(actual: T): BooleanExpect;
448
+ <T extends string>(actual: T): StringExpect;
449
+ <T extends symbol>(actual: T): SymbolExpect<T>;
450
+ <T>(actual: T): ValueExpect<T>;
451
+ fail: typeof fail;
452
+ }
453
+ type GetExpectType<T> = T extends number ? NumberExpect<T> : AllExpects<T>;
454
+ //# sourceMappingURL=expect.types.d.ts.map
455
+ //#endregion
456
+ export { ArrayExpect, BigIntExpect, BooleanExpect, DateExpect, Expect, FunctionExpect, Loose, MapExpect, NumberExpect, ObjectExpect, PromiseExpect, type State, StringExpect, SymbolExpect, ValueExpect };
457
+ //# sourceMappingURL=expect.types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expect.types.d.cts","names":[],"sources":["../src/utils/process-error.ts","../src/assert/throws.ts","../src/utils/fail.ts","../src/utils/types.ts","../src/utils/get-type.ts","../src/mixins.ts","../src/expect.types.ts"],"sourcesContent":[],"mappings":";AAEiB,UAAA,WAAW,CACF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