A JavaScript byte array library for the browser, Deno and Node.js
npm install @i-xi-dev/bytesA JavaScript byte array library for the browser, Deno and Node.js
These require Blob.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅
15.7+ |
This requires File.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅
19.2+ |
This requires ReadableStream.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅
16.5+ |
These require Request and Response.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅
18.0+ |
These require Crypto.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅
15.0+ |
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
| :---: | :---: | :---: | :---: | :---: | :---: |
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
``console`
$ npm i @i-xi-dev/bytes@4.4.2
`javascript`
import { ByteSequence, ByteOrder } from "@i-xi-dev/bytes";
Example for UNPKG
`javascript`
import { ByteSequence, ByteOrder } from "https://www.unpkg.com/@i-xi-dev/bytes@4.4.2/esm/mod.js";
---
#### Creating an instance
Creates an instance with a new underlying buffer
- ByteSequence.allocate()
- ByteSequence.generateRandom()
- ByteSequence.fromArrayBuffer()
- ByteSequence.fromArrayBufferView()
- ByteSequence.fromBufferSource()
- ByteSequence.fromArray()
- ByteSequence.fromUint8Iterable()
- ByteSequence.fromAsyncUint8Iterable()
- ByteSequence.fromUint16Iterable()
- ByteSequence.fromAsyncUint16Iterable()
- ByteSequence.fromUint32Iterable()
- ByteSequence.fromAsyncUint32Iterable()
- ByteSequence.fromBigUint64Iterable()
- ByteSequence.fromAsyncBigUint64Iterable()
- ByteSequence.from()
- ByteSequence.of()
- ByteSequence.fromBinaryString()
- ByteSequence.fromBase64Encoded()
- ByteSequence.fromPercentEncoded()
- ByteSequence.parse()
- ByteSequence.fromText()
- ByteSequence.fromBlob()
- ByteSequence.fromDataURL()
- ByteSequence.fromStream()
- ByteSequence.fromRequestOrResponse()
- ByteSequence.withMetadataFromBlob()
- ByteSequence.withMetadataFromDataURL()
- ByteSequence.withMetadataFromRequestOrResponse()
Creates an instance with the specified underlying buffer
- ByteSequence.wrapArrayBuffer()
---
#### Converting the instance to an ArrayBuffer
- ByteSequence.prototype.toArrayBuffer()
---
#### Converting the instance to an ArrayBufferView
- ByteSequence.prototype.toUint8Array()
- ByteSequence.prototype.toUint8ClampedArray()
- ByteSequence.prototype.toUint16Array()
- ByteSequence.prototype.toUint32Array()
- ByteSequence.prototype.toBigUint64Array()
- ByteSequence.prototype.toInt8Array()
- ByteSequence.prototype.toInt16Array()
- ByteSequence.prototype.toInt32Array()
- ByteSequence.prototype.toBigInt64Array()
- ByteSequence.prototype.toFloat32Array()
- ByteSequence.prototype.toFloat64Array()
- ByteSequence.prototype.toDataView()
- deprecated ByteSequence.prototype.toArrayBufferView()
---
#### Converting the instance to a number array
- ByteSequence.prototype.toUint8Iterable()
- ByteSequence.prototype.toUint16Iterable()
- ByteSequence.prototype.toUint32Iterable()
- ByteSequence.prototype.toBigUint64Iterable()
- ByteSequence.prototype.toArray()
- ByteSequence.prototype.toJSON()
---
#### Converting the instance to a binary string
- ByteSequence.prototype.toBinaryString()
---
#### Converting the instance to a string containing Base64 encoded bytes
- ByteSequence.prototype.toBase64Encoded()
---
#### Converting the instance to a string containing percent encoded bytes
- ByteSequence.prototype.toPercentEncoded()
---
#### Converting the instance to a string based on the specified format
- ByteSequence.prototype.format()
- ByteSequence.prototype.toString()
---
#### Converting the instance to a text
- ByteSequence.prototype.toText()
---
#### Converting the instance to a Blob
- ByteSequence.prototype.toBlob()
---
#### Converting the instance to a File
Node.js not support the File object
- ByteSequence.prototype.toFile()
---
#### Converting the instance to a data URL
- ByteSequence.prototype.toDataURL()
---
#### Converting the instance to a ReadableStream
- ByteSequence.prototype.toStream()
---
#### Converting the instance to a Request
- ByteSequence.prototype.toRequest()
---
#### Converting the instance to a Response
- ByteSequence.prototype.toResponse()
---
#### Generating a digest of the instance
- ByteSequence.prototype.toSha256Digest()
- ByteSequence.prototype.toSha384Digest()
- ByteSequence.prototype.toSha512Digest()
- ByteSequence.prototype.toSha1Digest()
- ByteSequence.prototype.toMd5Digest()
- ByteSequence.prototype.toDigest()
---
#### Generating a subresource integrity value of the instance
- ByteSequence.prototype.sha256Integrity
- ByteSequence.prototype.sha384Integrity
- ByteSequence.prototype.sha512Integrity
---
#### Editing the byte sequence
Gets the underlying ArrayBuffer
- ByteSequence.prototype.buffer
Gets the ArrayBufferView that views the underlying ArrayBuffer
- ByteSequence.prototype.asUint8Array()
- ByteSequence.prototype.asUint8ClampedArray()
- ByteSequence.prototype.asUint16Array()
- ByteSequence.prototype.asUint32Array()
- ByteSequence.prototype.asBigUint64Array()
- ByteSequence.prototype.asInt8Array()
- ByteSequence.prototype.asInt16Array()
- ByteSequence.prototype.asInt32Array()
- ByteSequence.prototype.asBigInt64Array()
- ByteSequence.prototype.asFloat32Array()
- ByteSequence.prototype.asFloat64Array()
- ByteSequence.prototype.asDataView()
- deprecated ByteSequence.prototype.getUint8View()
- deprecated ByteSequence.prototype.getDataView()
- deprecated ByteSequence.prototype.getView()
---
#### Duplicating the byte sequence
Duplicates with the new underlying ArrayBuffer
- ByteSequence.prototype.duplicate()
Duplicates the subsequence with the new underlying ArrayBuffer`
- ByteSequence.prototype.subsequence()
- ByteSequence.prototype.segment()
---
#### Comparing the byte sequence
- ByteSequence.prototype.equals()
- ByteSequence.prototype.startsWith()