buffer2uint8
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

npm install --save buffer2uint8

Usage

import buffer2uint8 from 'buffer2uint8';

const buffer = new Buffer ( 'hello' );
const uint8 = buffer2uint8 ( buffer ); // => Uint8Array (5) [ 104, 101, 108, 108, 111 ]

License

MIT © Fabio Spampinato

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i buffer2uint8

    Weekly Downloads

    1

    Version

    1.0.0

    License

    none

    Unpacked Size

    3.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • fabiospampinato