@@ -2,7 +2,8 @@ import stampit from 'stampit';
2
2
import { propEq } from 'ramda' ;
3
3
import { isNotUndefined , isString } from 'ramda-adjunct' ;
4
4
5
- import { Reference as IReference , ReferenceSet as IReferenceSet } from './types' ;
5
+ import { ReferenceSet as IReferenceSet } from './types' ;
6
+ import type Reference from './Reference' ;
6
7
7
8
const ReferenceSet : stampit . Stamp < IReferenceSet > = stampit ( {
8
9
props : {
@@ -12,15 +13,15 @@ const ReferenceSet: stampit.Stamp<IReferenceSet> = stampit({
12
13
} ,
13
14
init ( { refs = [ ] } = { } ) {
14
15
this . refs = [ ] ;
15
- refs . forEach ( ( ref : IReference ) => this . add ( ref ) ) ;
16
+ refs . forEach ( ( ref : Reference ) => this . add ( ref ) ) ;
16
17
} ,
17
18
methods : {
18
19
get size ( ) : number {
19
20
// @ts -ignore
20
21
return this . refs . length ;
21
22
} ,
22
23
23
- add ( reference : IReference ) : IReferenceSet {
24
+ add ( reference : Reference ) : IReferenceSet {
24
25
if ( ! this . has ( reference ) ) {
25
26
this . refs . push ( reference ) ;
26
27
this . rootRef = this . rootRef === null ? reference : this . rootRef ;
@@ -36,12 +37,12 @@ const ReferenceSet: stampit.Stamp<IReferenceSet> = stampit({
36
37
return this ;
37
38
} ,
38
39
39
- has ( thing : string | IReference ) : boolean {
40
+ has ( thing : string | Reference ) : boolean {
40
41
const uri = isString ( thing ) ? thing : thing . uri ;
41
42
return isNotUndefined ( this . find ( propEq ( uri , 'uri' ) ) ) ;
42
43
} ,
43
44
44
- find ( callback ) : IReference | undefined {
45
+ find ( callback ) : Reference | undefined {
45
46
return this . refs . find ( callback ) ;
46
47
} ,
47
48
@@ -50,8 +51,8 @@ const ReferenceSet: stampit.Stamp<IReferenceSet> = stampit({
50
51
} ,
51
52
52
53
clean ( ) {
53
- this . refs . forEach ( ( ref : IReference ) => {
54
- ref . refSet = null ; // eslint-disable-line no-param-reassign
54
+ this . refs . forEach ( ( ref : Reference ) => {
55
+ ref . refSet = undefined ; // eslint-disable-line no-param-reassign
55
56
} ) ;
56
57
this . rootRef = null ;
57
58
this . refs = [ ] ;
0 commit comments