Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: don't use bigint literals #597

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/sync/core-sync-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function createState({ have, prehave, want, status }) {
const bigInt = BigInt(want)
// 53 because the max safe integer in JS is 53 bits
for (let i = 0; i < 53; i++) {
if ((bigInt >> BigInt(i)) & 1n) {
if ((bigInt >> BigInt(i)) & BigInt(1)) {
peerState.setWantRange({ start: i, length: 1 })
}
}
Expand All @@ -433,7 +433,7 @@ function createBitfield(bits) {
const bigInt = BigInt(bits)
// 53 because the max safe integer in JS is 53 bits
for (let i = 0; i < 53; i++) {
bitfield.set(i, !!((bigInt >> BigInt(i)) & 1n))
bitfield.set(i, !!((bigInt >> BigInt(i)) & BigInt(1)))
}
return bitfield
}
Expand All @@ -451,7 +451,7 @@ async function clearCore(core, bits) {
const promises = []
// 53 because the max safe integer in JS is 53 bits
for (let i = 0; i < core.length; i++) {
if ((bigInt >> BigInt(i)) & 1n) continue
if ((bigInt >> BigInt(i)) & BigInt(1)) continue
promises.push(core.clear(i))
}
await Promise.all(promises)
Expand All @@ -470,7 +470,7 @@ async function downloadCore(core, bits) {
const blocks = []
// 53 because the max safe integer in JS is 53 bits
for (let i = 0; i < core.length; i++) {
if ((bigInt >> BigInt(i)) & 1n) {
if ((bigInt >> BigInt(i)) & BigInt(1)) {
blocks.push(i)
}
}
Expand All @@ -491,7 +491,7 @@ function setPeerWants(state, peerId, bits) {
const ranges = []
// 53 because the max safe integer in JS is 53 bits
for (let i = 0; i < 53; i++) {
if ((bigInt >> BigInt(i)) & 1n) {
if ((bigInt >> BigInt(i)) & BigInt(1)) {
ranges.push({ start: i, length: 1 })
}
}
Expand Down
Loading