{"id":15598830,"url":"https://github.com/lukechilds/byte-range","last_synced_at":"2025-04-28T10:28:52.777Z","repository":{"id":57192084,"uuid":"165189536","full_name":"lukechilds/byte-range","owner":"lukechilds","description":"Returns integer ranges for C data types","archived":false,"fork":false,"pushed_at":"2019-01-12T04:42:45.000Z","size":12,"stargazers_count":32,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T15:16:31.185Z","etag":null,"topics":["c","data-type","validation"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukechilds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-11T06:12:58.000Z","updated_at":"2023-09-08T17:49:10.000Z","dependencies_parsed_at":"2022-09-01T06:02:20.644Z","dependency_job_id":null,"html_url":"https://github.com/lukechilds/byte-range","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fbyte-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fbyte-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fbyte-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechilds%2Fbyte-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukechilds","download_url":"https://codeload.github.com/lukechilds/byte-range/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251294512,"owners_count":21566295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","data-type","validation"],"created_at":"2024-10-03T01:41:28.684Z","updated_at":"2025-04-28T10:28:52.739Z","avatar_url":"https://github.com/lukechilds.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# byte-range\n\n\u003e Returns integer ranges for a given number of bytes.\n\n[![Build Status](https://travis-ci.com/lukechilds/byte-range.svg?branch=master)](https://travis-ci.com/lukechilds/byte-range)\n[![Coverage Status](https://coveralls.io/repos/github/lukechilds/byte-range/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/byte-range?branch=master)\n[![npm](https://img.shields.io/npm/v/byte-range.svg)](https://www.npmjs.com/package/byte-range)\n\nReturns 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.\n\n## Install\n\n```shell\nnpm install byte-range\n```\n\n## Usage\n\nCheck the integer range for a given number of bytes:\n\n```js\nconst byteRange = require('byte-range');\n\nbyteRange(1);\n// [0, 255]\nbyteRange(2);\n// [0, 65535]\n```\n\nYou can check signed or unsigned integer ranges:\n\n```js\nbyteRange(1, {signed: false});\n// [0, 255]\nbyteRange(1, {signed: true});\n// [-128, 127]\n```\n\nThere are also some common C data types precomputed:\n\n```js\nbyteRange.uint8;\n// [0, 255]\nbyteRange.uint16;\n// [0, 65535]\nbyteRange.uint32;\n// [0, 4294967295]\nbyteRange.int8;\n// [-128, 127]\nbyteRange.int16;\n// [-32768, 32767]\nbyteRange.int32;\n// [-2147483648, 2147483647]\n```\n\n## API\n\n### byteRange(bytes, [options])\n\nReturns integer ranges for a given number of bytes.\n\n#### bytes\n\nType: `number`\u003cbr /\u003e\nDefault: `undefined`\n\nNumber of bytes to return the integer range for. Must be a positive integer.\n\n#### options\n\nType: `Object`\u003cbr /\u003e\nDefault: `{signed: false}`\n\nAn object containing the following properties:\n\n##### signed\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nA boolean indicating whether the integer range is signed.\n\n### byteRange.uint8\n\nPrecomputed byte range for an unsigned 8 bit integer.\n\n### byteRange.uint16\n\nPrecomputed byte range for an unsigned 16 bit integer.\n\n### byteRange.uint32\n\nPrecomputed byte range for an unsigned 32 bit integer.\n\n### byteRange.int8\n\nPrecomputed byte range for a signed 8 bit integer.\n\n### byteRange.int16\n\nPrecomputed byte range for a signed 16 bit integer.\n\n### byteRange.int32\n\nPrecomputed byte range for a signed 32 bit integer.\n\n## License\n\nMIT © Luke Childs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechilds%2Fbyte-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukechilds%2Fbyte-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechilds%2Fbyte-range/lists"}