
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Easy way to encode / decode JavaScript objects in binary format with support for Date, ArrayBuffer and Node.js Buffer.
Easy way to encode / decode JavaScript objects in binary format with support for Date, ArrayBuffer and Node.js Buffer.
yarn add binobject
import { ObjectEncoder, ObjectDecoder } from 'binobject';
import { randomBytes } from 'crypto';
const sourceObject = {
users: [{
name: 'Astrid',
birthday: new Date(),
uniqueSignature: randomBytes(256)
}]
};
const buffer = new ObjectEncoder().encode(sourceObject);
assert.deepEqual(new ObjectDecoder(buffer).decode(), sourceObject);
Both encoder and decoder class give you the possibility to define custom types for encoding and decoding. All you have to do is create a processor to decode and encode your custom type and then define a value. When defining a custom type it's important not to override a default type, you can check a full list starting from here. Also you need to be aware that currently this library support only up to 255 types (custom types included). See an example bellow:
import { BinaryObject, Processor } from 'binobject';
import { ObjectID } from 'mongodb';
import { deepEqual } from 'assert';
class ProcessorObjectID extends Processor<ObjectID> {
validate(id: any): boolean {
return id instanceof ObjectID == true;
}
decode(buffer: Buffer): ObjectID {
return new ObjectID(buffer.toString('hex'));
}
encode(input: ObjectID): Buffer {
return Buffer.from(input.toHexString(), 'hex');
}
}
const binaryObject = new BinaryObject([{
processor: new ProcessorObjectID,
value: 60
}]);
const buffer = binaryObject.encode({
_id: new ObjectID()
});
deepEqual(binaryObject.decode(buffer), {
_id: new ObjectID()
});
Need more examples? Check out our test.ts file
FAQs
Easy way to encode / decode JavaScript objects in binary format with support for Date, ArrayBuffer and Node.js Buffer.
The npm package binobject receives a total of 2 weekly downloads. As such, binobject popularity was classified as not popular.
We found that binobject demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.