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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bitfriendly

v1.1.2

Published

Customizable binary format with bitwise operations

Downloads

1

Readme

BitFriendly

License: MIT

BitFriendly makes it easier to work with bitwise operations or bit shifts in Javascript on arbitrarily sized binary numbers, allowing more freedom than the built-in 32-bit numbers for fun and profit. ;)

Installation

The preferred method of installation is using npm:

$ npm install bitfriendly --save

To install BitFriendly temporarily and not add it to the dependencies list:

$ npm install bitfriendly --no-save

You can also download the latest zip file or copy and use the Javascript file directly.

Features

  • Binary numbers of arbitrary size
  • Conventional bitwise operations and bit shifts
  • More binary maths coming soon...

Usage

// First, require the library, this returns a object with two functions -
// "bitArray(vals)" for constructing an array of boolean values to represent our binary number...
// and "operate(arr)" for carrying out bitwise operations and bit shifts
const lib = require("./src/index.js");

// Pure strings and arrays of mixed 1, 0, true, false are allowed for constructor
const binaryNumberFromString = lib.bitArray("100101");
console.log(binaryNumberFromString);

const binaryNumberFromMixedArray = lib.bitArray([1, false, false, true, "0", 1]);
console.log(binaryNumberFromMixedArray);

console.log(lib.operate(binaryNumberFromString).eql(binaryNumberFromMixedArray).toString());

// We can also alias the function for cleaner code
const bin = lib.bitArray;
const op = lib.operate;

// Now let's do some math!
const a = bin("11011101");
const b = bin("01000100");

const aPlusB = op(a).add(b);
// toString() converts the boolean array to a string consists of 0's and 1's
console.log(aPlusB.toString());

const awesome = aNotPlusBThenRotateToRightWithCarry = op(a).not().add(b).rcr();
console.log(awesome.toString());

const thenXorB = awesome.xor(b);
console.log(thenXorB.toString());

// More operators and toString(options) or toInt() functions are being added! ;)

Why Create BitFriendly?

It's fun to explore the binary world. BitFriendly utilizes Javascript arrays and booleans instead of real Javascript binary numbers, so it's not speedy at all, but it's much more flexible. BitFriendly is created for my own need for implementing a Javascript simulator of the Minimal Machine (MIMA) (see MIMA Aufgaben and MIMA Simulator), which is used in the computer engineering lectures at Karlsruhe Institute of Technology.

Project Status

The current version of BitFriendly supports these operations - AND, OR, XOR, NOT, EQL and ADD, as well as one kind of bit shift RCR (Rotate with Carry to the Right). There will also be more algorithmic operators like subtraction and division, together with more bit shift options. More interaction friendly toString and toInt functions are coming too.

License

BitFriendly is distributed under the MIT License. For more information, read the file LICENSE.