Skip to content

Commit

Permalink
Use shift to define parse integer.
Browse files Browse the repository at this point in the history
See #567.
  • Loading branch information
flatheadmill committed Jul 29, 2020
1 parent d139b51 commit d0a2707
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions hex.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function hex (value) {
switch (typeof value) {
case 'bigint':
case 'number':
return `0x${value.toString(16)}`
case 'object':
Expand Down
2 changes: 1 addition & 1 deletion parse.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function generate (packet, { require, bff, chk }) {
while (bite != stop) {
reads.unshift(`${cast.to}($buffer[$start++])`)
if (bite) {
reads[0] += ` * 0x${(256n ** BigInt(bite)).toString(16)}${cast.suffix}`
reads[0] += ` * ${hex(1n << BigInt(bite) * 8n)}${cast.suffix}`
}
bite += direction
}
Expand Down

0 comments on commit d0a2707

Please sign in to comment.