Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
token-types
Advanced tools
The token-types npm package provides a collection of token parsers for binary data types, facilitating the reading and interpretation of various data types from binary streams. This is particularly useful in applications dealing with multimedia files, where metadata and content need to be extracted or interpreted from binary formats.
Reading integer values
This feature allows the reading of unsigned 32-bit integers from a buffer in little-endian format. It is useful for parsing low-level binary data structures.
const Token = require('token-types');
const uint32Token = Token.UINT32_LE;
const buffer = Buffer.from([0x01, 0x00, 0x00, 0x00]);
const value = uint32Token.get(buffer, 0);
console.log(value); // Outputs: 1
Reading string values
This feature enables the extraction of ASCII strings from binary data. It supports specifying the length of the string and the encoding, making it versatile for reading text data embedded in binary streams.
const Token = require('token-types');
const stringToken = new Token.StringType(5, 'ascii');
const buffer = Buffer.from('hello');
const value = stringToken.get(buffer, 0);
console.log(value); // Outputs: 'hello'
binary-parser offers functionality to build a schema for parsing binary data, which is somewhat similar to token-types. However, binary-parser is more comprehensive in defining complex parsing schemas, making it suitable for applications that require detailed and structured binary data interpretation.
A primitive token library used to read from, and to write a node Buffer
.
node-strtok
supports a wide variety of numerical tokens out of the box:
UINT8
UINT16_BE
, UINT16_LE
UINT24_BE
, UINT24_LE
UINT32_BE
, UINT32_LE
INT8
INT16_BE
, INT16_LE
INT24_BE
, INT24_LE
INT32_BE
, INT32_LE
One might notice that there is no support for 64-bit tokens, since JavaScript seems to limit value size to less than 2^64. Rather than wrapping up an additional math library to handle this, I wanted to stick with JavaScript primitives. Maybe this will change later if this becomes important.
FAQs
Common token types for decoding and encoding numeric and string values
The npm package token-types receives a total of 2,334,549 weekly downloads. As such, token-types popularity was classified as popular.
We found that token-types demonstrated a healthy version release cadence and project activity because the last version was released less than 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.