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

hipack

v1.0.4

Published

HiSpeed Pack/Unpack of bytes formats, just like PHP and PERL

Downloads

7

Readme

HiPack

This is a copy of PHP's pack/unpack function made into a nodejs module. Its a 100% clone with an additional options.

  • A new feature where we can populate an existing Buffer is now there, so the caller can worry about Buffer management. Simply make the first parameter a buffer

  • Also we can supply an array of values, rather than arguments, so the 2nd parameter is an array. ie. pack( "VV", [ 23,55 ] );

  • Added a Perl style format that was missing, which is format character "V" and "v"

Install

To install HiPack, use npm

$ npm install hipack

Packing Bytes Test

To test packing bytes, run $ node test/test.js $ node test/speedtest.js $ node example/packit.js CCCC 25 26 27 27

To use in code, var pack = require( 'hipack' ).pack; var buffer = pack( "CCCV", [ 1,2,3, 12345679 ] );

Original Pack Documentation

pack - Pack data into binary Buffer object

Description

Buffer object = pack ( [ DestBuffer ] , string format [, mixed $args [, mixed n... ]] ) Pack given arguments into a binary Buffer according to format.

The idea for this function was taken from Perl and all formatting codes work the same as in Perl. However, there are some formatting codes that are missing such as Perl's "u" format code.

Note that the distinction between signed and unsigned values only affects the function unpack(), where as function pack() gives the same result for signed and unsigned format codes.

Parameters

format

The format string consists of format codes followed by an optional repeater argument. The repeater argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H the repeat count specifies how many characters of one data argument are taken, for @ it is the absolute position where to put the next data, for everything else the repeat count specifies how many data arguments are consumed and packed into the resulting binary string.

Currently implemented formats are:

pack() format characters

Code | Description -----|------------ a | NUL-padded string A | SPACE-padded string h | Hex string, low nibble first H | Hex string, high nibble first c | signed char C | unsigned char s | signed short (always 16 bit, machine byte order) S | unsigned short (always 16 bit, machine byte order) n | unsigned short (always 16 bit, big endian byte order) v | unsigned short (always 16 bit, little endian byte order) i | signed integer (machine dependent size and byte order) I | unsigned integer (machine dependent size and byte order) l | signed long (always 32 bit, machine byte order) L | unsigned long (always 32 bit, machine byte order) N | unsigned long (always 32 bit, big endian byte order) V | unsigned long (always 32 bit, little endian byte order) f | float (machine dependent size and representation) d | double (machine dependent size and representation) x | NUL byte X | Back up one byte Z | NUL-padded string (new in PHP 5.5) @ | NUL-fill to absolute position

Return Values

Returns a Buffer containing data.

unpack

unpack - Unpack data from a Buffer

Description

Object unpack ( String format , Buffer data, [ Boolean PerlFormat ] ) Unpacks from a binary string into an array according to the given format.

The unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /. If a repeater argument is present, then each of the array keys will have a sequence number behind the given name.

Example: "c2chars/nints" will return an object with fields Object = { chars1: 0, chars2: 0, ints: 0 }.

Parameters

format See pack() for an explanation of the format codes.

data The packed data.

PerlFormat If this parameter exists and is true, we will ignore the PHP style names, and use just the variables index

Example: "c2n" will return an object with fields Object = { 1: 0, 2: 0, 3: 0 }

Return Values

Returns an associative array containing unpacked elements of binary string.