npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@g-js-api/binary

v1.0.4

Published

A toolkit for G.js that allows you to do bit-level manipulation and reading (binary conversion to triggers, bitwise operators, 2^x exponentiation, etc.)

Readme

g.js-binary

A toolkit for G.js that allows you to do bit-level manipulation and reading (binary conversion to triggers, bitwise operators, 2^x exponentiation, etc.)

Example

import '@g-js-api/g.js';
import Binary from '@g-js-api/binary'

await $.exportConfig({
    type: 'live_editor',
    options: { info: true }
});

let binary = new Binary(16); // MUST be run before anything else!

let block = unknown_g();
object({
    OBJ_ID: 1,
    X: 15,
    Y: -75,
    GROUPS: block
}).add();

// does 2 ^ 5
let res1 = binary.pow2(5);
res1.display(45, -15);

// moves `block` by 32 (2 ^ 5) steps
binary.convert(res1, (exp) => {
  block.move(exp, 0);
})

// does `res1 << 2`
let res2 = binary.bitwise(res1, LSHIFT, 2);
res2.display(75, -15);

Docs

Class Binary:

  • Argument to constructor: the maximum amount of bits that will be used
  • Usage: new Binary(16)

Methods:

  • .bitwise: Does a bitwise operation on two values (one for NOT)
    • Parameters:
      • value1 (number / counter): The first value to the operation
      • op (number): The bitwise operator (AND, OR, XOR, LSHIFT, RSHIFT, NAND, NOR, NOT, XNOR)
      • value2 (number / counter): The second value to the operation (optional only for NOT operator)
      • copy (boolean, optional, default = true): Whether to copy to a new counter or to directly return the counter used in the backend
      • delay (number, optional, default = true): Whether to delay by a small amount (do NOT disable unless you're working on very low-level stuff!)
  • .pow2: Calculates 2^x
    • Parameters:
      • exp (number): The exponent to base 2
      • copy (boolean, optional, default = true): Whether to copy to a new counter or to directly return the counter used in the backend
  • convert: Converts a counter to triggers by repeatedly subtracting powers of two (only works on additive triggers, e.g. move, rotate, scale)
    • Parameters:
      • value (counter): The counter to convert into triggers
      • fn (function): The function that holds the triggers
        • Parameters passed to function: exp, which stores the current power of two
      • delay (number, optional, default = true): Whether to delay by a small amount (do NOT disable unless you're working on very low-level stuff!)