{"_id":"big-varint","_rev":"4577447","name":"big-varint","description":"Encode and decode arbitrarily large signed and unsigned BigInts","dist-tags":{"latest":"0.2.1"},"maintainers":[{"name":"joelg","email":""}],"time":{"modified":"2026-04-10T15:47:33.000Z","created":"2021-07-09T19:58:57.466Z","0.2.1":"2024-10-17T19:05:45.639Z","0.2.0":"2024-10-17T15:54:09.598Z","0.1.3":"2021-11-08T01:29:34.040Z","0.1.2":"2021-09-01T20:14:22.647Z","0.1.1":"2021-08-26T15:43:17.974Z","0.1.0":"2021-07-09T19:58:57.466Z"},"users":{},"author":{"name":"Joel Gustafson"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"versions":{"0.2.1":{"name":"big-varint","version":"0.2.1","description":"Encode and decode arbitrarily large signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","exports":{".":"./lib/index.js","./signed":"./lib/signed.js","./unsigned":"./lib/unsigned.js"},"scripts":{"build":"tsc --build tsconfig.json test/tsconfig.json","dev":"tsc --build tsconfig.json test/tsconfig.json --watch","clean":"tsc --build tsconfig.json test/tsconfig.json --clean","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"@ava/typescript":"^5.0.0","@types/node":"^22.7.6","ava":"^6.1.3","typescript":"^5.6.3"},"_id":"big-varint@0.2.1","gitHead":"5602634adcb73adbc03d2374026b4b0ae72aa7b8","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"shasum":"bc9ecc10c23cfd7151cfc7475bb8ca4ec25e6f32","size":3245,"noattachment":false,"key":"/big-varint/-/big-varint-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.2.1.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.2.1_1729191945432_0.18412495896975822"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-17T19:05:45.639Z","publish_time":1729191945639,"_source_registry_name":"default","_cnpm_publish_time":1729191945639},"0.2.0":{"name":"big-varint","version":"0.2.0","description":"Encode and decode arbitrarily large signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","exports":{".":"./lib/index.js","./signed":"./lib/signed.js","./unsigned":"./lib/unsigned.js"},"scripts":{"build":"tsc --build tsconfig.json test/tsconfig.json","dev":"tsc --build tsconfig.json test/tsconfig.json --watch","clean":"tsc --build tsconfig.json test/tsconfig.json --clean","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"@ava/typescript":"^5.0.0","@types/node":"^22.7.6","ava":"^6.1.3","typescript":"^5.6.3"},"_id":"big-varint@0.2.0","gitHead":"20a230d0ca16a0163fe6a07465640a5fde0723bf","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"shasum":"f2478be4770517bee13a52b26340ebfb86aa36ed","size":3239,"noattachment":false,"key":"/big-varint/-/big-varint-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.2.0.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.2.0_1729180449389_0.5616317821667121"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-17T15:54:09.598Z","publish_time":1729180449598,"_source_registry_name":"default","_cnpm_publish_time":1729180449598},"0.1.3":{"name":"big-varint","version":"0.1.3","description":"Encode and decode arbitrarily large signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"ava":"^4.0.0-rc.1","typescript":"^4.3.4"},"gitHead":"5c17a49510d3e3e0212c915c883c36a0f1ed8d7d","_id":"big-varint@0.1.3","_nodeVersion":"16.9.0","_npmVersion":"8.1.1","dist":{"shasum":"e6ba78d2ad131a53ee6a0ae2a0db1d6fc55d21e5","size":3052,"noattachment":false,"key":"/big-varint/-/big-varint-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.1.3.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.1.3_1636334973885_0.6832753697195186"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T18:07:13.582Z","publish_time":1636334974040,"_cnpm_publish_time":1636334974040},"0.1.2":{"name":"big-varint","version":"0.1.2","description":"Encode and decode arbitrarily large signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"ava":"^4.0.0-alpha.2","ts-node":"^10.0.0","typescript":"^4.3.4"},"gitHead":"93d2c543e6b25006662bac55553441c57885c73d","_id":"big-varint@0.1.2","_nodeVersion":"14.17.4","_npmVersion":"7.21.1","dist":{"shasum":"5c75c866f244f49151e95f92bbc0487ec4d42b70","size":3073,"noattachment":false,"key":"/big-varint/-/big-varint-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.1.2.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.1.2_1630527262498_0.5362307400827202"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T18:07:12.683Z","publish_time":1630527262647,"_cnpm_publish_time":1630527262647},"0.1.1":{"name":"big-varint","version":"0.1.1","description":"Encode and decode arbitrarily large signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"ava":"^4.0.0-alpha.2","ts-node":"^10.0.0","typescript":"^4.3.4"},"gitHead":"36cf90c4a83b6ee395341a32f1cccb8e92d601bb","_id":"big-varint@0.1.1","_nodeVersion":"14.17.4","_npmVersion":"7.20.3","dist":{"shasum":"73c0acf8ea9639cda464b9a0be7d1f4995c7bca3","size":3459,"noattachment":false,"key":"/big-varint/-/big-varint-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.1.1.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.1.1_1629992597888_0.11910045342568232"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T18:07:11.783Z","publish_time":1629992597974,"_cnpm_publish_time":1629992597974},"0.1.0":{"name":"big-varint","version":"0.1.0","description":"Encode and decode signed and unsigned BigInts","type":"module","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/joeltg/big-varint.git"},"keywords":["bigint","varint","signed-varint"],"author":{"name":"Joel Gustafson"},"license":"MIT","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"homepage":"https://github.com/joeltg/big-varint#readme","devDependencies":{"ava":"^4.0.0-alpha.2","ts-node":"^10.0.0","typescript":"^4.3.4"},"gitHead":"159aa277639efe6b26a82dccf5a36b431b18688b","_id":"big-varint@0.1.0","_nodeVersion":"16.3.0","_npmVersion":"7.17.0","dist":{"shasum":"3a7b3f56321d578a57c4179d5356059bf01a133d","size":2376,"noattachment":false,"key":"/big-varint/-/big-varint-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/big-varint/download/big-varint-0.1.0.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.1.0_1625860737356_0.30895828790377955"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T18:07:10.891Z","publish_time":1625860737466,"_cnpm_publish_time":1625860737466}},"readme":"# big-varint\n\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme) [![license](https://img.shields.io/github/license/joeltg/big-varint)](https://opensource.org/licenses/MIT) [![NPM version](https://img.shields.io/npm/v/big-varint)](https://www.npmjs.com/package/big-varint) ![TypeScript types](https://img.shields.io/npm/types/big-varint)\n\nEncode and decode arbitrarily large signed and unsigned BigInts.\n\nThis library is TypeScript-native, ESM-only, and has zero dependencies. It uses Uint8Arrays and works in the browser, Node, and [Deno](https://deno.land/). It uses the same binary encoding as Go's [encoding/binary](https://pkg.go.dev/encoding/binary) module, the [Protobuf spec](https://developers.google.com/protocol-buffers/docs/encoding), and the [varint](https://www.npmjs.com/package/varint) / [signed-varint](https://www.npmjs.com/package/signed-varint) NPM packages.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Testing](#testing)\n- [Credits](#credits)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n```\nnpm i big-varint\n```\n\n## Usage\n\n### Encode a Signed Varint\n\n```ts\nimport { encode } from \"big-varint/signed\"\n\nconst i = -300n\n\nencode(i) // Uint8Array(2) [ 215, 4 ]\n```\n\n### Decode a Signed Varint\n\n```ts\nimport { decode } from \"big-varint/signed\"\n\nconst data = new Uint8Array([215, 4])\n\ndecode(data) // -300n\n```\n\n`decode` can also be passed an optional `offset` parameter:\n\n```ts\nimport { decode } from \"big-varint/signed\"\n\nconst data = new Uint8Array([0, 0, 215, 4, 37, 37, 37])\n\ndecode(data, 2) // -300n\n\n// The encoding length of the most recently decoded value\n// can be accessed via the `decode.bytes` property.\ndecode.bytes // 2\n```\n\n### Get the Encoding Length of a Signed Varint\n\n```ts\nimport { encodingLength } from \"big-varint/signed\"\n\nconst i = -300n\n\nencodingLength(i) // 2\n```\n\n### Encode an Unsigned Varint\n\n```ts\nimport encode from \"big-varint/unsigned\"\n\nconst i = 123456789012345678901234567890n\n\nencode(i)\n\n/*\nUint8Array(14) [\n  210, 149, 252, 241,\n  228, 157, 248, 185,\n  195, 237, 191, 200,\n  238,  49\n]\n*/\n```\n\n### Decode an Unsigned Varint\n\n```ts\nimport { decode } from \"big-varint/unsigned\"\n\nconst data = new Uint8Array([210, 149, 252, 241, 228, 157, 248, 185, 195, 237, 191, 200, 238, 49])\n\ndecode(data) // 123456789012345678901234567890n\n```\n\n`decode` can also be passed an optional `offset` parameter:\n\n```typescript\nimport { decode } from \"big-varint/unsigned\"\n\nconst data = new Uint8Array([\n\t0, 0, 0, 0, 210, 149, 252, 241, 228, 157, 248, 185, 195, 237, 191, 200, 238, 49, 37, 37, 0, 0,\n])\n\ndecode(data, 4) // 123456789012345678901234567890n\n\n// The encoding length of the most recently decoded value\n// can be accessed via the `decode.bytes` property.\ndecode.bytes // 14\n```\n\n### Get the Encoding Length of an Unsigned Varint\n\n```typescript\nimport { encodingLength } from \"big-varint/unsigned\"\n\nconst i = 123456789012345678901234567890n\n\nencodingLength(i) // 14\n```\n\n## Testing\n\nTests use [AVA](https://github.com/avajs/ava) and live in the [test](./test/) directory.\n\n```\nnpm run test\n```\n\n## Credits\n\nA previous version of this library was adapted from [chrisdickinson/varint](https://github.com/chrisdickinson/varint), but has since been rewritten from scratch.\n\n## Contributing\n\nI don't expect to add any additional functionality to this library, but am potentially open to proposals for better interfaces. Open issues to discuss any questions before making an PRs.\n\n## License\n\nMIT © 2021 Joel Gustafson\n","_attachments":{},"homepage":"https://github.com/joeltg/big-varint#readme","bugs":{"url":"https://github.com/joeltg/big-varint/issues"},"license":"MIT"}