Package Exports
- uint1array
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uint1array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🎐 Uint1Array

JavaScript's missing TypedArray. Bit-level view of any underlying ArrayBuffer.
API
The API simply mirrors a regular TypedArray.
Differences from the TypedArray API
The 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.split('').map( c => c.charCodeAt(0) );
const buf = new ArrayBuffer(chars.length);
const bytes = new Uint8Array(buf);
const bits = new Uint1Array(buf);
bytes.set(chars);
console.log(`${bits}`); // 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 ]