{"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":{"integrity":"sha512-bNRO9fwiaorK2i9hqX7PwzZt9DH/FsIjudFPFAQ4eB8+LEYQ9G6XOyvREzMX6wdCd9GtHmysgxPgpo+muHA0Qg==","shasum":"73c0acf8ea9639cda464b9a0be7d1f4995c7bca3","tarball":"http://registry-npm.ywwl.com/big-varint/download/big-varint-0.1.1.tgz","fileCount":21,"unpackedSize":8702,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhJ7aVCRA9TVsSAnZWagAAE2gP/jXPquuIFds+hJBKIGEw\n6NMaBxpz47iTTtet+b+gOlnTBXNaqd2FyV/qdVPmk1N7wPQ2rTBN7skowsz9\nIeZYGP5c1g5kZWBSnMEDs+S5ii6fhuWI9WK93DDg1+tXboi1zbIvSGRJa+6A\nvIEg/z6O64FANTPZbLiEjhrO/mS+TWMmeOLOn7uQFTV46lyesXEDC9z0kt/B\nGdBraTRMjssMEzVaOpraCFKNOp5bzXUwymQavxtqxpNUytZFtqvxhLMaZazN\ngxcfW17H/qJuAo2uKY9jQPP3lPK4N9+PQpPn+b3+q26i9Gcn9oCvJ5jEEofZ\nmio90lO8uUu9NXIBkftQjex6uXf3K1XqwqaK+Nw87TXwXpU7cfhXJye5FKvb\n0Z2us+7FlaTqBUXZQLX08/QJvOy955JJY6zHwLM/q4IitH9mqPLOGIwhB+7W\nQCXyQ5Jl+8gMvQwZPm/rB1oxsXxcQgLgvo+RtqvUoFGy2/AUvWF2E/Z3nA6h\nLL+S4hMYHn7jc0GY4+FGsquFDhxz13YotCqqKsIlkVXoGvRFkWpuvo0kE78J\nHJTQZ0vbMpsUq3wVO0+w2wabXEff8/tDabvsWF5HBW5wzzAARJdKfweKd8cE\nueFp7Y/MojzbR6X5V0BsQuMcdSYLmmPfxw6P1C0eFWK9Aguwed6BFQVbKYZN\nssWg\r\n=Bm4G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCh7woat+DietYkq08ppPur92zjYRH2AOKHwID2O3mW7AIhAOYKWH3R1IFwAqRNv+G5PGjcwnkZV55mwWOjY/YHZ96/"}],"size":3459,"noattachment":false,"key":"/big-varint/-/big-varint-0.1.1.tgz"},"_npmUser":{"name":"joelg","email":"joelg@mit.edu"},"directories":{},"maintainers":[{"name":"joelg","email":"joelg@mit.edu"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/big-varint_0.1.1_1629992597888_0.11910045342568232"},"_hasShrinkwrap":false,"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) ![lines of code](https://img.shields.io/tokei/lines/github/joeltg/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\nOr in Deno:\n\n```typescript\nimport { signed, unsigned } from \"https://cdn.skypack.dev/big-varint\"\n\nsigned.encode(-2138912031n)\n```\n\n## Usage\n\n### Encode a Signed Varint\n\n```typescript\nimport { signed } from \"big-varint\"\n\nconst i = -300n\n\nsigned.encode(i) // Uint8Array(2) [ 215, 4 ]\n```\n\n### Decode a Signed Varint\n\n```typescript\nimport { signed } from \"big-varint\"\n\nconst data = new Uint8Array([215, 4])\n\nsigned.decode(data) // -300n\n```\n\n`decode` can also be passed an optional `offset` parameter:\n\n```typescript\nimport { signed } from \"big-varint\"\n\nconst data = new Uint8Array([0, 0, 215, 4, 37, 37, 37])\n\nsigned.decode(data, 2) // -300n\n```\n\n### Get the Encoding Length of a Signed Varint\n\n```typescript\nimport { signed } from \"big-varint\"\n\nconst i = -300n\n\nsigned.encodingLength(i) // 2\n```\n\n### Encode an Unsigned Varint\n\n```typescript\nimport { unsigned } from \"big-varint\"\n\nconst i = 123456789012345678901234567890n\n\nunsigned.encode(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```typescript\nimport { unsigned } from \"big-varint\"\n\nconst data = new Uint8Array([\n\t210, 149, 252, 241, 228, 157, 248, 185, 195, 237, 191, 200, 238, 49,\n])\n\nunsigned.decode(data) // 123456789012345678901234567890n\n```\n\n`decode` can also be passed an optional `offset` parameter:\n\n```typescript\nimport { unsigned } from \"big-varint\"\n\nconst data = new Uint8Array([\n\t0, 0, 0, 0, 210, 149, 252, 241, 228, 157, 248, 185, 195, 237, 191, 200, 238,\n\t49, 37, 37,\n])\n\nunsigned.decode(data, 4) // 123456789012345678901234567890n\n```\n\n### Get the Encoding Length of an Unsigned Varint\n\n```typescript\nimport { unsigned } from \"big-varint\"\n\nconst i = 123456789012345678901234567890n\n\nunsigned.encodingLength(i) // 14\n```\n\n## Testing\n\nTests use [AVA 4](https://github.com/avajs/ava) (currently in alpha) 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","publish_time":1629992597974,"_cnpm_publish_time":1629992597974,"dist-tags":{"latest":"0.2.1"}}