https://github.com/fabiospampinato/buffer2uint8
A tiny function for casting a Buffer to a Uint8Array.
https://github.com/fabiospampinato/buffer2uint8
buffer conversion uint8array
Last synced: 2 months ago
JSON representation
A tiny function for casting a Buffer to a Uint8Array.
- Host: GitHub
- URL: https://github.com/fabiospampinato/buffer2uint8
- Owner: fabiospampinato
- License: mit
- Created: 2022-04-09T14:17:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T00:54:54.000Z (11 months ago)
- Last Synced: 2025-09-15T00:43:17.629Z (3 months ago)
- Topics: buffer, conversion, uint8array
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Buffer2Uint8
A tiny function for casting a Buffer to a Uint8Array.
## Details
- The underlying ArrayBuffer is not copied, a new view into it is created.
- While Buffer extends Uint8Array the two don't work identically, and some times you actually just want to work with the real Uint8Array.
## Install
```sh
npm install buffer2uint8
```
## Usage
```ts
import buffer2uint8 from 'buffer2uint8';
// Let's convert a Buffer to a Uint8Array
const buffer = new Buffer ( 'hello' );
const uint8 = buffer2uint8 ( buffer ); // => Uint8Array (5) [ 104, 101, 108, 108, 111 ]
```
## License
MIT © Fabio Spampinato