{"id":13538407,"url":"https://github.com/craftzdog/react-native-buffer","last_synced_at":"2025-04-02T05:31:14.353Z","repository":{"id":48158969,"uuid":"337269375","full_name":"craftzdog/react-native-buffer","owner":"craftzdog","description":"The buffer module from node.js, for React Native","archived":false,"fork":true,"pushed_at":"2023-01-31T05:55:44.000Z","size":1314,"stargazers_count":108,"open_issues_count":7,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T04:33:23.332Z","etag":null,"topics":["react-native"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"feross/buffer","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/craftzdog.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":"2021-02-09T02:27:07.000Z","updated_at":"2025-02-25T03:38:12.000Z","dependencies_parsed_at":"2023-02-16T16:32:10.072Z","dependency_job_id":null,"html_url":"https://github.com/craftzdog/react-native-buffer","commit_stats":null,"previous_names":[],"tags_count":100,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-native-buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-native-buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-native-buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-native-buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftzdog","download_url":"https://codeload.github.com/craftzdog/react-native-buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763805,"owners_count":20829795,"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":["react-native"],"created_at":"2024-08-01T09:01:11.532Z","updated_at":"2025-04-02T05:31:14.048Z","avatar_url":"https://github.com/craftzdog.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# @craftzdog/react-native-buffer\n\n#### The buffer module from [node.js](https://nodejs.org/), for React Native.\n\nSimply `require('@craftzdog/react-native-buffer')` or use the `Buffer` global and you will get this module.\nIt internally uses [react-native-quick-base64](https://github.com/craftzdog/react-native-quick-base64), which is a performant native implementation of base64.\n\nThe goal is to provide an API that is 100% identical to\n[node's Buffer API](https://nodejs.org/api/buffer.html). Read the\n[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,\ninstance methods, and class methods that are supported.\n\n## install\n\n```bash\nnpm install @craftzdog/react-native-buffer react-native-quick-base64\ncd ios \u0026\u0026 pod install\n```\n\n## usage\n\nThe module's API is identical to node's `Buffer` API. Read the\n[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,\ninstance methods, and class methods that are supported.\n\nTo depend on this module explicitly, require it like this:\n\n```js\nimport { Buffer } from \"@craftzdog/react-native-buffer\";\n```\n\n## how does it work?\n\nThe Buffer constructor returns instances of `Uint8Array` that have their prototype\nchanged to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`,\nso the returned instances will have all the node `Buffer` methods and the\n`Uint8Array` methods. Square bracket notation works as expected -- it returns a\nsingle octet.\n\nThe `Uint8Array` prototype remains unmodified.\n\n## conversion packages\n\n### convert typed array to buffer\n\nUse [`typedarray-to-buffer`](https://www.npmjs.com/package/typedarray-to-buffer) to convert any kind of typed array to a `Buffer`. Does not perform a copy, so it's super fast.\n\n### convert buffer to typed array\n\n`Buffer` is a subclass of `Uint8Array` (which is a typed array). So there is no need to explicitly convert to typed array. Just use the buffer as a `Uint8Array`.\n\n### convert blob to buffer\n\nUse [`blob-to-buffer`](https://www.npmjs.com/package/blob-to-buffer) to convert a `Blob` to a `Buffer`.\n\n### convert buffer to blob\n\nTo convert a `Buffer` to a `Blob`, use the `Blob` constructor:\n\n```js\nvar blob = new Blob([buffer]);\n```\n\nOptionally, specify a mimetype:\n\n```js\nvar blob = new Blob([buffer], { type: \"text/html\" });\n```\n\n### convert arraybuffer to buffer\n\nTo convert an `ArrayBuffer` to a `Buffer`, use the `Buffer.from` function. Does not perform a copy, so it's super fast.\n\n```js\nvar buffer = Buffer.from(arrayBuffer);\n```\n\n### convert buffer to arraybuffer\n\nTo convert a `Buffer` to an `ArrayBuffer`, use the `.buffer` property (which is present on all `Uint8Array` objects):\n\n```js\nvar arrayBuffer = buffer.buffer.slice(\n  buffer.byteOffset,\n  buffer.byteOffset + buffer.byteLength\n);\n```\n\nAlternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-arraybuffer) module.\n\n## performance\n\n4x faster than base64-js on an iPhone 11 Pro when dealing with base64, thanks to [react-native-quick-base64](https://github.com/craftzdog/react-native-quick-base64).\n\n## credit\n\nThis was originally forked from [feross/buffer](https://github.com/feross/buffer).\n\n## Security Policies and Procedures\n\nThe `buffer` team and community take all security bugs in `buffer` seriously. Please see our [security policies and procedures](https://github.com/feross/security) document to learn how to report issues.\n\n## license\n\nMIT.\nCopyright (C) [Takuya Matsuyama](https://www.craftz.dog/), and other contributors.\nOriginally forked from an MIT-licensed module by [Feross Aboukhadijeh](http://feross.org) and Romain Beauxis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Freact-native-buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftzdog%2Freact-native-buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Freact-native-buffer/lists"}