-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13b6835
commit 564310b
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const bytes16 = (x: number, le = false) => { | ||
const b0 = x & 0xff; | ||
const b1 = (x >> 8) & 0xff; | ||
return le ? [b0, b1] : [b1, b0]; | ||
}; | ||
|
||
export const bytes24 = (x: number, le = false) => { | ||
const b0 = x & 0xff; | ||
const b1 = (x >> 8) & 0xff; | ||
const b2 = (x >> 16) & 0xff; | ||
return le ? [b0, b1, b2] : [b2, b1, b0]; | ||
}; | ||
|
||
export const bytes32 = (x: number, le = false) => { | ||
const b0 = x & 0xff; | ||
const b1 = (x >> 8) & 0xff; | ||
const b2 = (x >> 16) & 0xff; | ||
const b3 = (x >> 24) & 0xff; | ||
return le ? [b0, b1, b2, b3] : [b3, b2, b1, b0]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters