
Product
Go Support Is Now Generally Available
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
@binary-format/binary-format
Advanced tools
a typescript library for reading and writing binary files to and from plain javascript objects
a typescript library for reading and writing binary files to and from plain javascript objects.
there is a plethora of exiting libraries that accomplish the same goal, but all come with tradeoffs.
i am trading some speed in favor or using "plain" javascript objects that immer supports because i wanted to use immutable data structures while working on an online editor that supports the editing of various file formats.
import BinaryFormat from '@skratchdot/binary-format';
const helloWorldParser = new BinaryFormat<{
hello: string;
asciiSpace: number;
world: string;
asciiExclaimation: number;
}>()
.string('hello', 5)
.uint8('asciiSpace')
.string('world', 5)
.uint8('asciiExclaimation')
.done();
const buffer = Buffer.from('hello world!');
const readResult = helloWorldParser.read(buffer);
const writeResult = helloWorldParser.write(readResult);
console.log({ readResult, writeResult });
/*
{
readResult: {
hello: 'hello',
asciiSpace: 32,
world: 'world',
asciiExclaimation: 33
},
writeResult: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64 21>
}
*/
immer
)coming soon. for now check out the examples folder or the unit tests
export const stringWithLength = (length: number): ReadAndWrite => ({
read: (r: SmartBuffer) => r.readString(length),
write: (w: SmartBuffer, v: unknown) => w.writeString(String(v), length),
});
.assert(data => data.foo === 'must be this value')
to apitoArray()
take a funtion instead of a number as the only parameter (potentially other objects that take a length: string()
and buffer()
etc)typedarray
logic (maybe things like uint8array()
)toArray()
being called on bits()
?FAQs
a typescript library for reading and writing binary files to and from plain javascript objects
The npm package @binary-format/binary-format receives a total of 20 weekly downloads. As such, @binary-format/binary-format popularity was classified as not popular.
We found that @binary-format/binary-format 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.
Product
Socket's Go support is now generally available, bringing automatic scanning and deep code analysis to all users with Go projects.
Security News
vlt adds real-time security selectors powered by Socket, enabling developers to query and analyze package risks directly in their dependency graph.
Security News
CISA extended MITRE’s CVE contract by 11 months, avoiding a shutdown but leaving long-term governance and coordination issues unresolved.