
Security News
TC39 Advances Temporal to Stage 4 Alongside Several ECMAScript Proposals
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.
bit-twiddle
Advanced tools
This is a collection of miscellaneous bit twiddling hacks ported to JavaScript, mostly taken from here:
http://graphics.stanford.edu/~seander/bithacks.html
Via npm:
npm install bit-twiddle
sign(v)Computes the sign of the integer v. Returns:
abs(v)Returns the absolute value of the integer v
min(x,y)Computes the minimum of integers x and y
max(x,y)Computes the maximum of integers x and y
isPow2(v)Returns true if v is a power of 2, otherwise false.
log2(v)Returns an integer approximation of the log-base 2 of v
log10(v)Returns log base 10 of v.
popCount(v)Counts the number of bits set in v
countTrailingZeros(v)Counts the number of trailing zeros.
nextPow2(v)Rounds v up to the next power of 2.
prevPow2(v)Rounds v down to the previous power of 2.
parity(v)Computes the parity of the bits in v.
reverse(v)Reverses the bits of v.
interleave2(x,y)Interleaves a pair of 16 bit integers. Useful for fast quadtree style indexing. (See wiki: http://en.wikipedia.org/wiki/Z-order_curve )
deinterleave2(v, n)Deinterleaves the bits of v, returns the nth part. If both x and y are 16 bit, then it is true that:
deinterleave2(interleave2(x,y), 0) === x
deinterleave2(interleave2(x,y), 1) === y
interleave3(x,y,z)Interleaves a triple of 10 bit integers. Useful for fast octree indexing.
deinterleave3(v, n)Same deal as deinterleave2, only for triples instead of pairs
nextCombination(x)Returns next combination ordered colexicographically.
Code is ported from Sean Eron Anderson's public domain bit twiddling hacks page. http://graphics.stanford.edu/~seander/bithacks.html JavaScript implementation (c) 2013 Mikola Lysenko. MIT License
The bitwise package provides a comprehensive set of bitwise operations for JavaScript. It includes functions for bit manipulation, bitwise arithmetic, and more. Compared to bit-twiddle, bitwise offers a broader range of functionalities and is more actively maintained.
The bitset package allows for the manipulation of large sets of bits. It provides a BitSet class that supports various bitwise operations. While bitset is more focused on handling large bitsets efficiently, bit-twiddle is more about providing simple, low-level bitwise operations.
The bitwise-operator package offers a collection of bitwise operations similar to bit-twiddle. It includes functions for setting, clearing, toggling, and checking bits. However, bitwise-operator is less popular and less frequently updated compared to bit-twiddle.
FAQs
Bit twiddling hacks for JavaScript
The npm package bit-twiddle receives a total of 787,754 weekly downloads. As such, bit-twiddle popularity was classified as popular.
We found that bit-twiddle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
TC39’s March 2026 meeting advanced eight ECMAScript proposals, including Temporal reaching Stage 4 and securing its place in the ECMAScript 2026 specification.

Research
/Security News
Since January 31, 2026, we identified at least 72 additional malicious Open VSX extensions, including transitive GlassWorm loader extensions targeting developers.

Research
Six malicious Packagist packages posing as OphimCMS themes contain trojanized jQuery that exfiltrates URLs, injects ads, and loads FUNNULL-linked redirects.