Package Exports
- @i-xi-dev/bytes
Readme
@i-xi-dev/bytes
A JavaScript byte array library for the browser, Deno and Node.js
Requirement
ByteSequence.fromBlob and ByteSequence.prototype.toBlob methods
These require Blob.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ 15.7+ |
ByteSequence.prototype.toFile method
This requires File.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
ByteSequence.fromStream method
This requires ReadableStream.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ 16.5+ |
ByteSequence.fromRequestOrResponse, ByteSequence.prototype.toRequest and ByteSequence.prototype.toResponse methods
These require Request and Response.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ 18.0+ |
ByteSequence.generateRandom, ByteSequence.prototype.toSha256Digest, ByteSequence.prototype.toSha384Digest and ByteSequence.prototype.toSha512Digest methods, ByteSequence.prototype.sha256Integrity, ByteSequence.prototype.sha384Integrity and ByteSequence.prototype.sha512Integrity properties
These require Crypto.
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ 15.0+ |
Other than above
| Chrome | Edge | Firefox | Safari | Deno | Node.js |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Installation
npm
$ npm i @i-xi-dev/bytes@4.0.3import { ByteSequence } from "@i-xi-dev/bytes";CDN
Example for Skypack
import { ByteSequence } from "https://cdn.skypack.dev/@i-xi-dev/bytes@4.0.3";Usage
ByteSequence class
Creating an instance
Creates an instance with a new underlying buffer
Creates an instance with the specified underlying buffer
Converting the instance to an ArrayBuffer
Converting the instance to an ArrayBufferView
- ByteSequence.prototype.toUint8Array()
- ByteSequence.prototype.toDataView()
- ByteSequence.prototype.toArrayBufferView()
Converting the instance to a number array
Converting the instance to a binary string
Converting the instance to a string containing Base64 encoded bytes
Converting the instance to a string containing percent encoded bytes
Converting the instance to a string based on the specified format
Converting the instance to a text
Converting the instance to a Blob
Converting the instance to a File
Node.js not support the File object
Converting the instance to a data URL
Converting the instance to a Request
Converting the instance to a Response
Generating a digest of the instance
- ByteSequence.prototype.toSha256Digest()
- ByteSequence.prototype.toSha384Digest()
- ByteSequence.prototype.toSha512Digest()
- 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
Gets the ArrayBufferView that views the underlying ArrayBuffer
- ByteSequence.prototype.getUint8View()
- ByteSequence.prototype.getDataView()
- ByteSequence.prototype.getView()
Duplicating the byte sequence
Duplicates with the new underlying ArrayBuffer
Duplicates the subsequence with the new underlying ArrayBuffer