@@ -15,7 +15,7 @@ type bit = 0 | 1;
1515// It would be simple, but very inefficient to create a viewer each time.
1616// So instead, we create one (a Uint32Array instance), once for all,
1717// and resort to a weakmap to allow retrieving it later on.
18- const _views = new WeakMap < ArrayBuffer , Uint32Array > ( ) ;
18+ const _views = new WeakMap < ArrayBufferLike , Uint32Array > ( ) ;
1919
2020// // We could make it available to the outside world so it can benefit as well.
2121// // Should we prefer to keep this private, it would also be possible.
@@ -95,8 +95,9 @@ class BitArray implements Iterable<bit> {
9595 byteLength : number ;
9696 byteOffset : number ;
9797 length : number ;
98- prototype : object ;
99- [ Symbol . iterator ] : ( ) => Iterator < bit > ;
98+ readonly prototype : BitArray ;
99+ // @ts -expect-error: Function implementation comes later down in the file.
100+ [ Symbol . iterator ] ( ) : ArrayIterator < bit > ;
100101 [ index : number ] : bit ;
101102
102103 static BYTES_PER_ELEMENT = 1 / 8 ;
@@ -190,7 +191,7 @@ class BitArray implements Iterable<bit> {
190191 // .map( String )
191192 // // add one space between each byte - it could be argued
192193 // // if this is the right thing to do. I think it replaces
193- // // nicely the comma in the native TypedArry 's toString()
194+ // // nicely the comma in the native TypedArray 's toString()
194195 // // since here we are looking at bits.
195196 // // Most obvious alternative would probably be to remove
196197 // // completely this line. It is hard to read for a human,
@@ -289,7 +290,7 @@ class BitArray implements Iterable<bit> {
289290 ? { done : false , value : this [ currentIndex ++ ] }
290291 : ( { done : true } as IteratorResult < bit > ) ;
291292 } ,
292- } ;
293+ } as ArrayIterator < bit > ;
293294 }
294295}
295296
@@ -326,4 +327,4 @@ BitArray.prototype[Symbol.iterator] = BitArray.prototype.values;
326327// Object.setPrototypeOf( BitArray.prototype , Object.getPrototypeOf(Int8Array).prototype );
327328
328329export default BitArray ;
329- export { bit } ;
330+ export type { bit } ;
0 commit comments