@@ -91,7 +91,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
9191 }
9292 }
9393
94- const hasIterator = ( o : unknown ) : o is Iterable < unknown > =>
94+ const isIterable = ( o : unknown ) : o is Iterable < unknown > =>
9595 typeof o === 'object' && o !== null && Symbol . iterator in ( o as object )
9696
9797 const hasForEach = < U > (
@@ -100,7 +100,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
100100 typeof ( o as { forEach ?: unknown } ) . forEach === 'function'
101101
102102 const asIterable = < U > ( other : RSetLike < U > | Set < U > ) : Iterable < U > => {
103- if ( hasIterator ( other ) ) return other as Iterable < U >
103+ if ( isIterable ( other ) ) return other as Iterable < U >
104104 if ( hasForEach ( other ) ) {
105105 const acc : U [ ] = [ ]
106106 other . forEach ( ( v ) => acc . push ( v ) )
@@ -118,7 +118,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
118118 this : InternalProxySet < T > ,
119119 other : RSetLike < unknown > | Set < T > ,
120120 ) : Set < unknown > {
121- this . epoch
121+ this . epoch // touch property for tracking
122122 const otherSet = proxySet ( asIterable ( other ) )
123123 const result = proxySet < T > ( )
124124 for ( const value of this . values ( ) ) {
@@ -138,7 +138,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
138138 this : InternalProxySet < T > ,
139139 other : RSetLike < unknown > | Set < T > ,
140140 ) : Set < unknown > {
141- this . epoch
141+ this . epoch // touch property for tracking
142142 const otherSet = proxySet ( asIterable ( other ) )
143143 const result = proxySet < unknown > ( )
144144 for ( const v of this . values ( ) ) result . add ( v )
@@ -155,7 +155,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
155155 this : InternalProxySet < T > ,
156156 other : RSetLike < unknown > | Set < T > ,
157157 ) : Set < T > {
158- this . epoch
158+ this . epoch // touch property for tracking
159159 const otherSet = proxySet ( asIterable ( other ) )
160160 const result = proxySet < T > ( )
161161 for ( const v of this . values ( ) ) if ( ! otherSet . has ( v ) ) result . add ( v )
@@ -174,7 +174,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
174174 this : InternalProxySet < T > ,
175175 other : RSetLike < unknown > | Set < T > ,
176176 ) : Set < unknown > {
177- this . epoch
177+ this . epoch // touch property for tracking
178178 const otherSet = proxySet ( asIterable ( other ) )
179179 const result = proxySet < unknown > ( )
180180 for ( const v of this . values ( ) ) if ( ! otherSet . has ( v ) ) result . add ( v )
@@ -196,7 +196,7 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
196196 has ( value : T ) {
197197 const map = getMapForThis ( this )
198198 const v = maybeProxify ( value )
199- this . epoch
199+ this . epoch // touch property for tracking
200200 return map . has ( v )
201201 } ,
202202 add ( value : T ) {
@@ -229,31 +229,31 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
229229 if ( ! isProxy ( this ) ) {
230230 throw new Error ( 'Cannot perform mutations on a snapshot' )
231231 }
232- this . data . length = 0
232+ this . data . length = 0 // empty array
233233 this . index = 0
234234 this . epoch ++
235235 indexMap . clear ( )
236236 } ,
237237 forEach ( cb : ( value : T , valueAgain : T , set : Set < T > ) => void ) {
238- this . epoch
238+ this . epoch // touch property for tracking
239239 const map = getMapForThis ( this )
240240 map . forEach ( ( index ) => {
241241 cb ( this . data [ index ] ! , this . data [ index ] ! , this )
242242 } )
243243 } ,
244244 * values ( ) : SetIterator < T > {
245- this . epoch
245+ this . epoch // touch property for tracking
246246 const map = getMapForThis ( this )
247247 for ( const index of map . values ( ) ) {
248248 yield this . data [ index ] !
249249 }
250250 } ,
251251 keys ( ) : SetIterator < T > {
252- this . epoch
252+ this . epoch // touch property for tracking
253253 return this . values ( )
254254 } ,
255255 * entries ( ) : SetIterator < [ T , T ] > {
256- this . epoch
256+ this . epoch // touch property for tracking
257257 const map = getMapForThis ( this )
258258 for ( const index of map . values ( ) ) {
259259 const value = this . data [ index ] !
@@ -274,18 +274,18 @@ export function proxySet<T>(initialValues?: Iterable<T> | null) {
274274 difference : differenceImpl ,
275275 symmetricDifference : symmetricDifferenceImpl ,
276276 isSubsetOf ( other : RSetLike < T > ) {
277- this . epoch
277+ this . epoch // touch property for tracking
278278 for ( const v of this . values ( ) ) if ( ! other . has ( v ) ) return false
279279 return true
280280 } ,
281281 isSupersetOf ( other : RSetLike < T > ) {
282- this . epoch
282+ this . epoch // touch property for tracking
283283 const it = asIterable ( other )
284284 for ( const v of it ) if ( ! this . has ( v ) ) return false
285285 return true
286286 } ,
287287 isDisjointFrom ( other : RSetLike < T > ) {
288- this . epoch
288+ this . epoch // touch property for tracking
289289 for ( const v of this . values ( ) ) if ( other . has ( v ) ) return false
290290 return true
291291 } ,
0 commit comments