@@ -2,44 +2,32 @@ export class Props {
22 #props = new Map < string , any > ( ) ;
33
44 constructor ( init ?: Record < string , any > ) {
5- for ( const [ key , value ] of Object . entries ( init || { } ) )
6- this . set ( key , value ) ;
5+ for ( const [ key , value ] of Object . entries ( init || { } ) ) this . set ( key , value ) ;
76 }
87
98 has ( key : string ) : boolean {
109 if ( ! key || typeof key != 'string' )
11- throw new TypeError (
12- `Expected key of type string, received ${ typeof key } ` ,
13- ) ;
10+ throw new TypeError ( `Expected key of type string, received ${ typeof key } ` ) ;
1411
1512 return this . #props. has ( key ) ;
1613 }
1714
1815 set < T > ( key : string , value : T ) : void {
1916 if ( ! key || typeof key != 'string' )
20- throw new TypeError (
21- `Expected key of type string, received ${ typeof key } ` ,
22- ) ;
17+ throw new TypeError ( `Expected key of type string, received ${ typeof key } ` ) ;
2318
24- if ( ! value )
25- throw new TypeError (
26- `Expected to receive a value, received ${ typeof value } ` ,
27- ) ;
19+ if ( ! value ) throw new TypeError ( `Expected to receive a value, received ${ typeof value } ` ) ;
2820
29- if ( this . has ( key ) )
30- throw new Error ( `Unable to overwrite the readonly prop: ${ key } ` ) ;
21+ if ( this . has ( key ) ) throw new Error ( `Unable to overwrite the readonly prop: ${ key } ` ) ;
3122
3223 this . #props. set ( key , value ) ;
3324 }
3425
3526 get < T > ( key : string ) : T {
3627 if ( ! key || typeof key != 'string' )
37- throw new TypeError (
38- `Expected key of type string, received ${ typeof key } ` ,
39- ) ;
28+ throw new TypeError ( `Expected key of type string, received ${ typeof key } ` ) ;
4029
41- if ( ! this . #props. has ( key ) )
42- throw new Error ( `Unable to find prop: ${ key } ` ) ;
30+ if ( ! this . #props. has ( key ) ) throw new Error ( `Unable to find prop: ${ key } ` ) ;
4331
4432 return this . #props. get ( key ) ;
4533 }
0 commit comments