{"id":13772470,"url":"https://github.com/LinusU/buffer-from","last_synced_at":"2025-05-11T04:31:24.938Z","repository":{"id":57190961,"uuid":"66025821","full_name":"LinusU/buffer-from","owner":"LinusU","description":"A ponyfill for Buffer.from","archived":false,"fork":false,"pushed_at":"2021-07-29T17:05:31.000Z","size":45,"stargazers_count":24,"open_issues_count":3,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-01T00:03:38.825Z","etag":null,"topics":[],"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/LinusU.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":"2016-08-18T19:44:34.000Z","updated_at":"2025-02-12T01:16:56.000Z","dependencies_parsed_at":"2022-09-15T22:21:27.780Z","dependency_job_id":null,"html_url":"https://github.com/LinusU/buffer-from","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Fbuffer-from","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Fbuffer-from/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Fbuffer-from/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinusU%2Fbuffer-from/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LinusU","download_url":"https://codeload.github.com/LinusU/buffer-from/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253518941,"owners_count":21921074,"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":[],"created_at":"2024-08-03T17:01:04.398Z","updated_at":"2025-05-11T04:31:24.337Z","avatar_url":"https://github.com/LinusU.png","language":"JavaScript","funding_links":[],"categories":["Node.js Features"],"sub_categories":[],"readme":"# Buffer From\n\nA [ponyfill](https://ponyfill.com) for `Buffer.from`, uses native implementation if available.\n\n## Installation\n\n```sh\nnpm install --save buffer-from\n```\n\n## Usage\n\n```js\nconst bufferFrom = require('buffer-from')\n\nconsole.log(bufferFrom([1, 2, 3, 4]))\n//=\u003e \u003cBuffer 01 02 03 04\u003e\n\nconst arr = new Uint8Array([1, 2, 3, 4])\nconsole.log(bufferFrom(arr.buffer, 1, 2))\n//=\u003e \u003cBuffer 02 03\u003e\n\nconsole.log(bufferFrom('test', 'utf8'))\n//=\u003e \u003cBuffer 74 65 73 74\u003e\n\nconst buf = bufferFrom('test')\nconsole.log(bufferFrom(buf))\n//=\u003e \u003cBuffer 74 65 73 74\u003e\n```\n\n## API\n\n### bufferFrom(array)\n\n- `array` \u0026lt;Array\u0026gt;\n\nAllocates a new `Buffer` using an `array` of octets.\n\n### bufferFrom(arrayBuffer[, byteOffset[, length]])\n\n- `arrayBuffer` \u0026lt;ArrayBuffer\u0026gt; The `.buffer` property of a TypedArray or ArrayBuffer\n- `byteOffset` \u0026lt;Integer\u0026gt; Where to start copying from `arrayBuffer`. **Default:** `0`\n- `length` \u0026lt;Integer\u0026gt; How many bytes to copy from `arrayBuffer`. **Default:** `arrayBuffer.length - byteOffset`\n\nWhen passed a reference to the `.buffer` property of a TypedArray instance, the\nnewly created `Buffer` will share the same allocated memory as the TypedArray.\n\nThe optional `byteOffset` and `length` arguments specify a memory range within\nthe `arrayBuffer` that will be shared by the `Buffer`.\n\n### bufferFrom(buffer)\n\n- `buffer` \u0026lt;Buffer\u0026gt; An existing `Buffer` to copy data from\n\nCopies the passed `buffer` data onto a new `Buffer` instance.\n\n### bufferFrom(string[, encoding])\n\n- `string` \u0026lt;String\u0026gt; A string to encode.\n- `encoding` \u0026lt;String\u0026gt; The encoding of `string`. **Default:** `'utf8'`\n\nCreates a new `Buffer` containing the given JavaScript string `string`. If\nprovided, the `encoding` parameter identifies the character encoding of\n`string`.\n\n## See also\n\n- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`\n- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLinusU%2Fbuffer-from","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLinusU%2Fbuffer-from","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLinusU%2Fbuffer-from/lists"}