{"_id":"@doomjs/ethereumjs-rlp","name":"@doomjs/ethereumjs-rlp","dist-tags":{"latest":"5.0.0"},"versions":{"5.0.0":{"name":"@doomjs/ethereumjs-rlp","version":"5.0.0","description":"Recursive Length Prefix Encoding Module","keywords":["rlp","ethereum"],"homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/rlp#readme","bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+rlp%22"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git"},"license":"MPL-2.0","author":{"name":"martin becze","email":"mjbecze@gmail.com"},"contributors":[{"name":"Alex Beregszaszi","email":"alex@rtfs.hu"},{"name":"Holger Drewes","email":"Holger.Drewes@gmail.com"},{"name":"Paul Miller","email":"pkg@paulmillr.com"}],"type":"module","main":"dist/cjs/index.js","module":"dist/esm/index.js","exports":{".":{"import":"./dist/esm/index.js","require":"./dist/cjs/index.js"}},"bin":{"rlp":"bin/rlp"},"scripts":{"build":"../../config/cli/ts-build.sh node","clean":"../../config/cli/clean-package.sh","coverage":"npx vitest run --coverage.enabled --coverage.reporter=lcov","examples":"ts-node ../../scripts/examples-runner.ts -- rlp","lint":"../../config/cli/lint.sh","lint:diff":"../../config/cli/lint-diff.sh","lint:fix":"../../config/cli/lint-fix.sh","test":"npm run test:node && npm run test:browser","test:browser":"npx vitest run --browser.name=chrome --browser.headless","test:node":"npx vitest run","tsc":"../../config/cli/ts-compile.sh"},"engines":{"node":">=18"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"types":"./dist/cjs/index.d.ts","gitHead":"c1950acac1518ff15dc128d58253df4de81760b8","_id":"@doomjs/ethereumjs-rlp@5.0.0","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-j1MijD9vile1XsIfalz41E7OIRucAyzYR0Q4WdI2cwEvq/V6pxW24/pgtrPlY5NfHuHI4dwSKjCkvqdgdx6meg==","shasum":"d8af7e4f27b64cc2c0e9c336bb1ac9a6b5f539a9","tarball":"https://registry.npmjs.org/@doomjs/ethereumjs-rlp/-/ethereumjs-rlp-5.0.0.tgz","fileCount":17,"unpackedSize":118713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDLshilt0ngsaWp83W4EbSgwk1QuixTcXS7BF46tIruJgIgB7COOG8FSmzIJ5rJMb9wVtIQm8zMqJquIksi7FGUQXE="}]},"_npmUser":{"name":"luoxm","email":"luoxianmingg@gmail.com"},"directories":{},"maintainers":[{"name":"luoxm","email":"luoxianmingg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ethereumjs-rlp_5.0.0_1689866366079_0.4480820935653862"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-20T15:19:25.955Z","5.0.0":"2023-07-20T15:19:26.277Z","modified":"2023-07-20T15:19:26.638Z"},"maintainers":[{"name":"luoxm","email":"luoxianmingg@gmail.com"}],"description":"Recursive Length Prefix Encoding Module","homepage":"https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/rlp#readme","keywords":["rlp","ethereum"],"repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-monorepo.git"},"contributors":[{"name":"Alex Beregszaszi","email":"alex@rtfs.hu"},{"name":"Holger Drewes","email":"Holger.Drewes@gmail.com"},{"name":"Paul Miller","email":"pkg@paulmillr.com"}],"author":{"name":"martin becze","email":"mjbecze@gmail.com"},"bugs":{"url":"https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+rlp%22"},"license":"MPL-2.0","readme":"# @ethereumjs/rlp\n\n[![NPM Package][rlp-npm-badge]][rlp-npm-link]\n[![GitHub Issues][rlp-issues-badge]][rlp-issues-link]\n[![Actions Status][rlp-actions-badge]][rlp-actions-link]\n[![Code Coverage][rlp-coverage-badge]][rlp-coverage-link]\n[![Discord][discord-badge]][discord-link]\n\nNote: this README has been updated containing the changes from our next breaking release round [UNRELEASED] targeted for Summer 2023. See the README files from the [maintenance-v6](https://github.com/ethereumjs/ethereumjs-monorepo/tree/maintenance-v6/) branch for documentation matching our latest releases.\n\n| [Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp) encoding for Node.js and the browser. |\n| ----------------------------------------------------------------------------------------------------------------------------------------- |\n\n## Installation\n\nTo obtain the latest version, simply require the project using `npm`:\n\n```shell\nnpm install @ethereumjs/rlp\n```\n\nInstall with `-g` if you want to use the CLI.\n\n## Usage\n\n```typescript\nimport assert from 'assert'\nimport { RLP } from '@ethereumjs/rlp'\n\nconst nestedList = [[], [[]], [[], [[]]]]\nconst encoded = RLP.encode(nestedList)\nconst decoded = RLP.decode(encoded)\nassert.deepEqual(nestedList, decoded)\n```\n\n## Browser\n\nWith the breaking release round in Summer 2023 we have added hybrid ESM/CJS builds for all our libraries (see section below) and have eliminated many of the caveats which had previously prevented a frictionless browser usage.\n\nIt is now easily possible to run a browser build of one of the EthereumJS libraries within a modern browser using the provided ESM build. For a setup example see [./examples/browser.html](./examples/browser.html).\n\n## API\n\n`RLP.encode(plain)` - RLP encodes an `Array`, `Uint8Array` or `String` and returns a `Uint8Array`.\n\n`RLP.decode(encoded, [stream=false])` - Decodes an RLP encoded `Uint8Array`, `Array` or `String` and returns a `Uint8Array` or `NestedUint8Array`. If `stream` is enabled, it will just decode the first rlp sequence in the Uint8Array. By default, it would throw an error if there are more bytes in Uint8Array than used by the rlp sequence.\n\n### Buffer compatibility\n\nIf you would like to continue using Buffers like in rlp v2, you can use:\n\n```typescript\nimport assert from 'assert'\nimport { arrToBufArr, bufArrToArr } from '@ethereumjs/util'\nimport { RLP } from '@ethereumjs/rlp'\n\nconst bufferList = [Buffer.from('123', 'hex'), Buffer.from('456', 'hex')]\nconst encoded = RLP.encode(bufArrToArr(bufferList))\nconst encodedAsBuffer = Buffer.from(encoded)\nconst decoded = RLP.decode(Uint8Array.from(encodedAsBuffer)) // or RLP.decode(encoded)\nconst decodedAsBuffers = arrToBufArr(decoded)\nassert.deepEqual(bufferList, decodedAsBuffers)\n```\n\n### Buffer -> Uint8Arrayy\n\nWith the breaking releases from Summer 2023 we have removed all Node.js specific `Buffer` usages from our libraries and replace these with [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) representations, which are available both in Node.js and the browser (`Buffer` is a subclass of `Uint8Array`).\n\nWe have converted existing Buffer conversion methods to Uint8Array conversion methods in the [@ethereumjs/util](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util) `bytes` module, see the respective README section for guidance.\n\n### BigInt Support\n\nStarting with v4 the usage of [BN.js](https://github.com/indutny/bn.js/) for big numbers has been removed from the library and replaced with the usage of the native JS [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) data type (introduced in `ES2020`).\n\nPlease note that number-related API signatures have changed along with this version update and the minimal build target has been updated to `ES2020`.\n\n## CLI\n\n`rlp encode <JSON string>`\\\n`rlp decode <0x-prefixed hex string>`\n\n### Examples\n\n- `rlp encode '5'` -> `0x05`\n- `rlp encode '[5]'` -> `0xc105`\n- `rlp encode '[\"cat\", \"dog\"]'` -> `0xc88363617483646f67`\n- `rlp decode 0xc88363617483646f67` -> `[\"cat\",\"dog\"]`\n\n## EthereumJS\n\nSee our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.\n\n## License\n\n[MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>)\n\n[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue\n[discord-link]: https://discord.gg/TNwARpR\n[rlp-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/rlp.svg\n[rlp-npm-link]: https://www.npmjs.com/package/@ethereumjs/rlp\n[rlp-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20rlp?label=issues\n[rlp-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A\"package%3A+rlp\"\n[rlp-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/rlp/badge.svg\n[rlp-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22rlp%22\n[rlp-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=rlp\n[rlp-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/rlp\n","readmeFilename":"README.md"}