@@ -2,8 +2,8 @@ import type { EncodedBlock } from './shared'
2
2
import { deflate } from 'pako'
3
3
import { getChecksum } from './checksum'
4
4
5
- export function createEncoder ( data : Uint8Array , indicesSize : number , compress = true ) : LtEncoder {
6
- return new LtEncoder ( data , indicesSize , compress )
5
+ export function createEncoder ( data : Uint8Array , sliceSize : number , compress = true ) : LtEncoder {
6
+ return new LtEncoder ( data , sliceSize , compress )
7
7
}
8
8
9
9
export class LtEncoder {
@@ -15,21 +15,21 @@ export class LtEncoder {
15
15
16
16
constructor (
17
17
public readonly data : Uint8Array ,
18
- public readonly indicesSize : number ,
18
+ public readonly sliceSize : number ,
19
19
public readonly compress = true ,
20
20
) {
21
21
this . compressed = compress ? deflate ( data ) : data
22
- this . indices = sliceData ( this . compressed , indicesSize )
22
+ this . indices = sliceData ( this . compressed , sliceSize )
23
23
this . k = this . indices . length
24
24
this . checksum = getChecksum ( this . data , this . k )
25
25
this . bytes = this . compressed . length
26
26
}
27
27
28
28
createBlock ( indices : number [ ] ) : EncodedBlock {
29
- const data = new Uint8Array ( this . indicesSize )
29
+ const data = new Uint8Array ( this . sliceSize )
30
30
for ( const index of indices ) {
31
31
const indicesIndex = this . indices [ index ] !
32
- for ( let i = 0 ; i < this . indicesSize ; i ++ ) {
32
+ for ( let i = 0 ; i < this . sliceSize ; i ++ ) {
33
33
data [ i ] = data [ i ] ! ^ indicesIndex [ i ] !
34
34
}
35
35
}
0 commit comments