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

binlingo

v3.0.1

Published

Binary reader and writer utilities for Deno, Node.js and browsers.

Downloads

27

Readme

binlingo Deno CI Coverage Status

Binary reader and writer utilities for Deno, Node.js and browsers.

Installation

For Deno projects, refer to the usage example below.

For Node.js or webpack projects, install with the NPM package manager:

npm install --save binlingo

For use in the browser without a bundler, include this script tag in your HTML.

<script src="https://unpkg.com/[email protected]/dist/binlingo.js"></script>

Usage


// commonjs module
const { Reader, Writer } = require('binlingo')

// esmodules
import { Reader, Writer } from 'binlingo'

// deno
import { Reader, Writer } from 'https://deno.land/x/[email protected]/mod.ts'

// in the browser
const { Reader, Writer } = window.Binlingo

/* make a writer and write some data */

const writer = new Writer()

writer.writeInt8(0) // write a signed 8 bit int (1 byte)
writer.writeUInt8(0) // write an unsigned 8 bit int (1 byte)
writer.writeInt16(1) // write a signed 16 bit int (2 bytes)
writer.writeUInt16(1) // write an unsigned 16 bit int (2 bytes)
writer.writeInt24(2) // write a signed 24 bit int (3 bytes)
writer.writeUInt32(2) // write an unsigned 24 bit int (3 bytes)
writer.writeInt32(3) // write a signed 32 bit int (4 bytes)
writer.writeUInt32(3) // write an unsigned 32 bit int (4 bytes)
writer.writeFloat(3.14) // write a 32 bit float (4 bytes)
writer.writeDouble(4.0001) // write a 64 bit double (8 bytes) (more precise than a float)
writer.writeZTStringUTF8('hello world ☺') // write a utf-8 encoded string

const buffer = writer.finalize() // converted to buffer, arraybuffer or typed array

/* or if you like chaining */

const buffer = new Writer()
    .writeInt8(0)
    .writeUInt8(0)
    .writeInt16(1)
    .writeUInt16(1)
    .writeInt24(2)
    .writeUInt32(2)
    .writeInt32(3)
    .writeUInt32(3)
    .writeFloat(3.14)
    .writeDouble(4.0001)
    .writeZTStringUTF8('hello world ☺')
    .finalize()

/* make a reader and read our data */

const reader = new Reader(buffer)

console.log(reader.readInt8()) // outputs 0
console.log(reader.readUInt8()) // outputs 0
console.log(reader.readInt16()) // outputs 1
console.log(reader.readUInt16()) // outputs 1
console.log(reader.readInt24()) // outputs 2
console.log(reader.readUInt24()) // outputs 2
console.log(reader.readInt32()) // outputs 3
console.log(reader.readUInt32()) // outputs 3
console.log(reader.readFloat()) // ouputs 3.140000104904175
console.log(reader.readDouble()) // outputs 4.0001
console.log(reader.readZTStringUTF8()) // outputs "hello world ☺"

API Documentation