Uint1Array

🎐 JavaScript's missing TypedArray. Bit-level view of any underlying ArrayBuffer.
API
The API simply mirrors a regular TypedArray.
TypedArray API
Differences from theThe only two differences are that Uint1Array has special cases of the following standard TypedArray
properties:
Uint1Array.BYTES_PER_ELEMENT
Returns a number value of the element size.
BYTES_PER_ELEMENT
equals 0.125 in the case of an Uint1Array.
Uint1Array.length
Static length property.
Static class member length
value is 0 in the case of Uint1Array.
For the actual length (number of bits), use <Uint1Array>.length
.
Get
npm install --save uint1array
Using
You can use like an ordinary TypedArray:
// pick an import style, either ESM or CommonJS // ESM// import Uint1Array from 'uint1array'; // CommonJS// const Uint1Array = require('uint1array').default; const message = "JAVASCRIPT ROCKS";const chars = message; const buf = charslength;const bytes = buf;const bits = buf; bytes; console; // Uint1Array [ 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0 ]