Catalog npm
PACKAGE EXPLORERView in registry

2pack

npm

Data serialization

dataserializationsockizy
Versions collected8
Direct dependencies8From release 1.0.0
Last observed20 Oct, 19:17 UTC

README

Current package documentation
  • Binary (Little/Big - Endian)
  • Relative and absolute zero-copy operations wherever possible
  • Browser

Goals:

  1. Low memory usage;
  2. Maximum performance.
const packer = require('2pack');

const header = packer('int16');
const payload = packer(['name:str', 'hp:int16']);

//------------------------------

payload.offset = header.maxSize;

//---------]>

const id = 69;
const data = { name: 'D', hp: 13 };

const buf = header.pack(id, payload.pack(data));
const size = buf.length;

//---------]>

console.log(packer.isBE, packer.isLE);

console.log(
    header.unpack(buf, 0, size),
    payload.unpack(buf, 0, size)
);

//------------------------------

/*
packer('int16'); // primitive | returns: value
pack(0);

packer(['int16']); // array | returns: array | unpackDataAsArray = true
pack([0]);

packer(['name:str']); // object | returns: object
pack(['D']);
pack({name: 'D'});

packer(['int16', 'name:str']); // error

//----)>

unpack(bin, offset, length, cbEndInfo(offset), target, asCopy, asArray);

@bin - Buffer / Uint8Array
*/
Packet type
NameAliasNote
-
bin<size (byte)>bdefault: max 1024 (0-65535); server: Buffer; client: Uint8Array;
str<size (byte)>sdefault: max 256 (0-65535)
int<size (bit)>isize: 8, 16, 32, 64 (BigInt64Array)
uint<size (bit)>usize: 8, 16, 32, 64 (BigUint64Array)
float<size (bit)>fsize: 32, 64
json<size (byte)>jdefault: max 8192 (0-65535)

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 8

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0Registry latest22 May 20228
0.1.27 Jun 201929
0.1.18 Jan 201929
0.1.025 Nov 201829
0.0.47 Feb 201829
0.0.36 Feb 201829
0.0.25 Feb 201829
0.0.15 Feb 201829

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
daeren/2pack

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:17 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:0b45b3d49cc23d96a871362fb0ad95a1d41cd37b6e059b8393cb250d1d28cd96