Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

construction

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

construction

Interface with binary structures in Javascript, built for network protocols.

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
5
-16.67%
Maintainers
1
Weekly downloads
 
Created
Source

construction

Interface with binary structures in Javascript, built for network protocols.

struct User {
	uint8_t age;
	int32_t favouriteNumber;
}
const Construction = requrie("construction");
const t = Construction.types;

const User = new Construction("LE", {
	age: t.UInt8;
	favouriteNumber: t.Int32
});

API

new Construction(endianness, object)

Create a new construction object.

// Endianness can be "LE" or "BE"

const User = new Construction("LE", {
	age: t.UInt8,
	favouriteNumber: t.Int32
});

buffer Construction#write(object)

Convert a javascript object to a binary buffer.

const buffer = User.write({
	age: 15,
	favouriteNumber: 1000000
});

console.log(buffer);
// <Buffer 0f 40 42 0f 00>

object Construction#read(buffer)

Convert a binary buffer to a javascript object.

const user = User.read(Buffer.from("0f40420f00", "hex"));

console.log(user);
// { age: 15, favouriteNumber: 1000000 }

FAQs

Package last updated on 04 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts