Skip to content

Commit

Permalink
modify: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ykisii committed Apr 26, 2023
1 parent 1ab2999 commit 2975aa6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions binary_to_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ export class BinaryToJSON {
}

private readBytes(br: BinaryReader, length: number): number {
const surplusLength = length >= 4 ? length - 4 : 0;
const bytes = br.readBytes(length);
let shift = 0x00;
let val = bytes.reduce((acc: number, val: number): number => {
let val = this.convolutionBytes(bytes);
return val;
}

private convolutionBytes(bytes: any): number {
let shift = 0;
return bytes.reduce((acc: number, val: number): number => {
let ret = 0;
if (this.#littlEndian) {
ret = acc | (val << shift)
Expand All @@ -90,7 +97,5 @@ export class BinaryToJSON {
}
return ret;
}, 0);

return val;
}
}

0 comments on commit 2975aa6

Please sign in to comment.