
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
Returns integer ranges for a given number of bytes.
Returns the integer range for a given number of bytes or a C data type. This is useful for validating values when dealing with low-level protocols or interfacing with other low-level languages.
npm install byte-range
Check the integer range for a given number of bytes:
const byteRange = require('byte-range');
byteRange(1);
// [0, 255]
byteRange(2);
// [0, 65535]
You can check signed or unsigned integer ranges:
byteRange(1, {signed: false});
// [0, 255]
byteRange(1, {signed: true});
// [-128, 127]
There are also some common C data types precomputed:
byteRange.uint8;
// [0, 255]
byteRange.uint16;
// [0, 65535]
byteRange.uint32;
// [0, 4294967295]
byteRange.int8;
// [-128, 127]
byteRange.int16;
// [-32768, 32767]
byteRange.int32;
// [-2147483648, 2147483647]
Returns integer ranges for a given number of bytes.
Type: number
Default: undefined
Number of bytes to return the integer range for. Must be a positive integer.
Type: Object
Default: {signed: false}
An object containing the following properties:
Type: boolean
Default: false
A boolean indicating whether the integer range is signed.
Precomputed byte range for an unsigned 8 bit integer.
Precomputed byte range for an unsigned 16 bit integer.
Precomputed byte range for an unsigned 32 bit integer.
Precomputed byte range for a signed 8 bit integer.
Precomputed byte range for a signed 16 bit integer.
Precomputed byte range for a signed 32 bit integer.
MIT © Luke Childs
FAQs
Returns integer ranges for a given number of bytes
We found that byte-range 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
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.