Spaces:
Sleeping
Sleeping
File size: 662 Bytes
cd6720a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //#region src/utils/bufferUtils.ts
const encoder = new TextEncoder();
function encodeBuffer(text) {
return encoder.encode(text);
}
function decodeBuffer(buffer, encoding) {
return new TextDecoder(encoding).decode(buffer);
}
/**
* Create an `ArrayBuffer` from the given `Uint8Array`.
* Takes the byte offset into account to produce the right buffer
* in the case when the buffer is bigger than the data view.
*/
function toArrayBuffer(array) {
return array.buffer.slice(array.byteOffset, array.byteOffset + array.byteLength);
}
//#endregion
export { encodeBuffer as n, toArrayBuffer as r, decodeBuffer as t };
//# sourceMappingURL=bufferUtils-DxPxwff_.mjs.map |