Modern ECMAScript ECMAScript

11. Binary Streams, Buffers & Container Layouts

Execute native browser-level Base64 and Hex conversions, stream async iterables, and construct modular container-responsive interfaces.

binary-streams.ts
typescript
// 1. Native Uint8Array Base64/Hex conversions
const encoder = new TextEncoder();
const payloadBytes = encoder.encode('Web Engine 2026 Protocol');
const base64Data = payloadBytes.toBase64(); // Standard zero-dependency encoding
const hexSignature = payloadBytes.toHex(); // "57656220456e67696e65..."
// 2. Async Iterable Streaming with Array.fromAsync
async function* streamDataChunks() {
yield Promise.resolve({ chunkIndex: 0, size: 256 });
yield Promise.resolve({ chunkIndex: 1, size: 512 });
}
const fullStreamArray = await Array.fromAsync(streamDataChunks());

Binary Streams, Buffers & Container Layouts

Native binary buffer transformations eliminate client-side polyfills for cryptography, file processing, and network serialisation.

  • Uint8Array.prototype.toBase64(): Browser-native, specification-grade Base64 conversion without string corruption or memory overhead.
  • Uint8Array.prototype.toHex(): Fast hexadecimal serialisation for hashes, tokens, and cryptographic signatures.
  • Array.fromAsync(): Consumes asynchronous iterables, ReadableStreams, and Promise batches directly into an array in a single operation.
Container Query & Binary Conversion Lab @container
Container Width:
Allocated Bytes

28 B

Base64 Length

40 Chars

Uint8Array.toBase64():

TW9kZXJuIFdlYiBBcmNoaXRlY3R1cmUgMjAyNg==

Uint8Array.toHex():

4d6f6465726e20576562204172636869746563747572652032303236