1+ import { assert } from '../assert' ;
2+ import type { AssertionResult } from '../assert' ;
13import type { Constructor } from '@colonise/utilities' ;
2- import { assert , AssertionResult } from '../assert' ;
34
45export interface AChain < TSubject > {
56
@@ -65,14 +66,9 @@ export interface AnChain<TSubject> {
6566 */
6667 < TExpected extends string > ( expected : TExpected ) : AssertionResult < TSubject , TSubject , TExpected > ;
6768
68- /**
69- * @example expect(actual).to.be.an.object()
70- */
71- // eslint-disable-next-line @typescript-eslint/ban-types
72- object ( ) : AssertionResult < TSubject , TSubject , object > ;
73-
7469 instance : {
7570 of : {
71+
7672 /**
7773 * @example expect(actual).to.be.an(expected)
7874 *
@@ -86,22 +82,28 @@ export interface AnChain<TSubject> {
8682 * @param expected
8783 */
8884 < TExpected extends string > ( expected : TExpected ) : AssertionResult < TSubject , TSubject , TExpected > ;
89- }
90- }
85+ } ;
86+ } ;
87+
88+ /**
89+ * @example expect(actual).to.be.an.object()
90+ */
91+ // eslint-disable-next-line @typescript-eslint/ban-types
92+ object ( ) : AssertionResult < TSubject , TSubject , object > ;
9193}
9294
95+ // eslint-disable-next-line max-lines-per-function
9396export function createAOrAnChain < TSubject > ( subject : TSubject , reverse : boolean = false ) : AChain < TSubject > & AnChain < TSubject > {
94- return Object . defineProperties (
97+ return < AChain < TSubject > & AnChain < TSubject > > Object . defineProperties (
9598 // eslint-disable-next-line id-length, prefer-arrow-callback
9699 function a < TExpected extends Constructor < TSubject > | string > (
97100 expected : TExpected
98101 ) : AssertionResult < TSubject , TSubject , TExpected > {
99102 if ( typeof expected === 'string' ) {
100103 return < AssertionResult < TSubject , TSubject , TExpected > > < unknown > assert ( subject ) . isTypeOf ( < 'string' > expected , reverse ) ;
101104 }
102- else {
103- return < AssertionResult < TSubject , TSubject , TExpected > > assert ( subject ) . isAnInstanceOf ( < Constructor < TSubject > > expected , reverse ) ;
104- }
105+
106+ return < AssertionResult < TSubject , TSubject , TExpected > > assert ( subject ) . isAnInstanceOf ( < Constructor < TSubject > > expected , reverse ) ;
105107 } ,
106108 {
107109 string : {
@@ -119,7 +121,7 @@ export function createAOrAnChain<TSubject>(subject: TSubject, reverse: boolean =
119121 return assert ( subject ) . isTypeOf ( 'bigint' , reverse ) ;
120122 }
121123 } ,
122- boolean : {
124+ ' boolean' : {
123125 value ( ) : AssertionResult < TSubject , TSubject , boolean > {
124126 return assert ( subject ) . isTypeOf ( 'boolean' , reverse ) ;
125127 }
@@ -129,25 +131,26 @@ export function createAOrAnChain<TSubject>(subject: TSubject, reverse: boolean =
129131 return assert ( subject ) . isTypeOf ( 'symbol' , reverse ) ;
130132 }
131133 } ,
132- // eslint-disable-next-line @typescript-eslint/ban-types
133- function : {
134+ 'function' : {
135+ // eslint-disable-next-line @typescript-eslint/ban-types
134136 value ( ) : AssertionResult < TSubject , TSubject , Function > {
135137 return assert ( subject ) . isTypeOf ( 'function' , reverse ) ;
136138 }
137139 } ,
138- // eslint-disable-next-line @typescript-eslint/ban-types
139140 object : {
141+ // eslint-disable-next-line @typescript-eslint/ban-types
140142 value ( ) : AssertionResult < TSubject , TSubject , object > {
141143 return assert ( subject ) . isTypeOf ( 'object' , reverse ) ;
142144 }
143145 } ,
144146 instance : {
145147 get ( ) {
146148 return {
147- of : function ( expected : Constructor ) {
149+ // eslint-disable-next-line id-length
150+ of ( expected : Constructor ) {
148151 return assert ( subject ) . isAnInstanceOf ( expected , reverse ) ;
149152 }
150- }
153+ } ;
151154 }
152155 }
153156 }
0 commit comments