UNPKG

ts-mls

Version:

[![CI](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml/badge.svg)](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [![npm version](https://badge.fury.io/js/ts-mls.svg)](https://badge.fury.io/js/ts-mls) [![Coverage Status](https://co

27 lines 831 B
export function bytesToBuffer(b) { return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength); } export function bytesToBase64(bytes) { if (typeof Buffer !== "undefined") { return Buffer.from(bytes).toString("base64"); } else { let binary = ""; bytes.forEach((b) => (binary += String.fromCharCode(b))); return globalThis.btoa(binary); } } export function base64ToBytes(base64) { if (typeof Buffer !== "undefined") { return Uint8Array.from(Buffer.from(base64, "base64")); } else { const binary = globalThis.atob(base64); const bytes = new Uint8Array(binary.length); for (let i = 0; i < binary.length; i++) { bytes[i] = binary.charCodeAt(i); } return bytes; } } //# sourceMappingURL=byteArray.js.map