@@ -7,18 +7,18 @@ import ArrayFixed from './ArrayFixed.js';
77 * Class representing a fixed size dense array.
88 * This ensures that mutation always results in a dense array.
99 */
10- class ArrayFixedDense < item , direction : boolean > extends ArrayFixed < item > {
10+ class ArrayFixedDense < item > extends ArrayFixed< item > {
1111
12- _direction : direction ;
12+ _direction : boolean ;
1313
1414 constructor (
1515 sizeOrArray : number | Array < item > = 0 ,
16- direction_ : direction = true
16+ direction : boolean = true
1717 ) {
1818 if ( Array . isArray ( sizeOrArray ) ) {
1919 // $FlowFixMe: Arrays are objects
2020 const arrayNew = Object . keys ( sizeOrArray ) . map ( ( k ) => sizeOrArray [ k ] ) ;
21- if ( direction_ ) {
21+ if ( direction ) {
2222 arrayNew . length = sizeOrArray . length ;
2323 sizeOrArray = arrayNew ;
2424 } else {
@@ -28,38 +28,38 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
2828 }
2929 }
3030 super ( sizeOrArray ) ;
31- this . _direction = direction_ ;
31+ this . _direction = direction ;
3232 }
3333
3434 /**
3535 * Construct from reference.
3636 * This skips the integrity process in the normal constructor.
3737 * The array must already be dense, and have the correct count and direction.
3838 */
39- static fromArray < direction : boolean > (
39+ static fromArray (
4040 array : Array < item > ,
4141 count : number ,
42- direction_ : direction = true
43- ) : ArrayFixedDense < item , direction > {
42+ direction : boolean = true
43+ ) : ArrayFixedDense < item > {
4444 const arrayFixedDense = new ArrayFixedDense ( array . length ) ;
4545 arrayFixedDense . _array = array ;
4646 arrayFixedDense . _count = count ;
47- arrayFixedDense . _direction = direction_ ;
47+ arrayFixedDense . _direction = direction ;
4848 return arrayFixedDense ;
4949 }
5050
5151 get direction ( ) : boolean {
5252 return this . _direction ;
5353 }
5454
55- switchDirection ( direction_ : direction ) : void {
56- if ( direction_ !== this . _direction ) {
57- if ( direction_ ) {
55+ switchDirection ( direction : boolean ) : void {
56+ if ( direction !== this . _direction ) {
57+ if ( direction ) {
5858 super . collapseLeft ( ) ;
5959 } else {
6060 super . collapseRight ( ) ;
6161 }
62- this . _direction = direction_ ;
62+ this . _direction = direction ;
6363 }
6464 }
6565
@@ -109,7 +109,7 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
109109 }
110110 }
111111
112- reverse ( ) : ArrayFixedDense < item , direction > {
112+ reverse ( ) : ArrayFixedDense < item > {
113113 let swapStart, swapMid;
114114 if ( this . _direction ) {
115115 swapStart = 0 ;
@@ -148,7 +148,7 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
148148 slice (
149149 begin : number = 0 ,
150150 end : number = this . _array . length
151- ) : ArrayFixedDense < item , direction > {
151+ ) : ArrayFixedDense < item > {
152152 begin = Math . trunc ( begin ) ;
153153 end = Math . trunc ( end ) ;
154154 if ( begin < 0 ) {
@@ -174,7 +174,7 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
174174 indexStart : number = 0 ,
175175 deleteCount : ?number ,
176176 ...items : Array < item >
177- ) : ArrayFixedDense < item , direction > {
177+ ) : ArrayFixedDense < item > {
178178 indexStart = Math . trunc ( indexStart ) ;
179179 if ( indexStart < 0 ) {
180180 indexStart = Math . max ( indexStart + this . _array . length , 0 ) ;
@@ -213,19 +213,19 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
213213 }
214214
215215 map < itemNew > (
216- callback : ( item , number , ArrayFixedDense < item , direction > ) => itemNew
217- ) : ArrayFixedDense < itemNew , direction > {
216+ callback : ( item , number , ArrayFixedDense < item > ) => itemNew
217+ ) : ArrayFixedDense < itemNew > {
218218 const arrayNew = this . _array . map ( ( v , i ) => callback ( v , i , this ) ) ;
219219 return ArrayFixedDense . fromArray ( arrayNew , this . _count , this . _direction ) ;
220220 }
221221
222222 forEach (
223- callback : ( item , number , ArrayFixedDense < item , direction > ) => any
223+ callback : ( item , number , ArrayFixedDense < item > ) => any
224224 ) : void {
225225 this. _array . forEach ( ( v , i ) => callback ( v , i , this ) ) ;
226226 }
227227
228- caretLeft ( index : number , value : item ) : void {
228+ caretLeft ( index : number , value : item ) : number {
229229 if ( index >= this . _array . length || index < 0 ) {
230230 throw new RangeError ( 'Out of range index' ) ;
231231 }
@@ -254,10 +254,10 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
254254 }
255255 this . _array [ index ] = value ;
256256 ++ this . _count ;
257- return ;
257+ return index ;
258258 }
259259
260- caretRight ( index : number , value : item ) : void {
260+ caretRight ( index : number , value : item ) : number {
261261 if ( index >= this . _array . length || index < 0 ) {
262262 throw new RangeError ( 'Out of range index' ) ;
263263 }
@@ -285,10 +285,10 @@ class ArrayFixedDense<item, direction: boolean> extends ArrayFixed<item> {
285285 }
286286 this . _array [ index ] = value ;
287287 ++ this . _count ;
288- return ;
288+ return index ;
289289 }
290290
291- caret ( index : number , value : item ) : void {
291+ caret ( index : number , value : item ) : number {
292292 // the preferred direction is the opposite direction of this dense array
293293 if ( this . _direction ) {
294294 return this . caretRight ( index , value ) ;
0 commit comments