Spaces:
Running
Running
Download node_modules/@mswjs/interceptors/src/utils/bufferUtils.ts from fffiloni/live-vision: direct link, hf CLI and curl.
- Browser
- Download file 635 Bytes
-
https://huggingface.co/spaces/fffiloni/live-vision/resolve/main/node_modules/%40mswjs/interceptors/src/utils/bufferUtils.ts
- Command line
-
hf download hf://spaces/fffiloni/live-vision/node_modules/@mswjs/interceptors/src/utils/bufferUtils.ts
-
curl -L -o bufferUtils.ts https://huggingface.co/spaces/fffiloni/live-vision/resolve/main/node_modules/%40mswjs/interceptors/src/utils/bufferUtils.ts
635 Bytes
| const encoder = new TextEncoder() | |
| export function encodeBuffer(text: string): Uint8Array { | |
| return encoder.encode(text) | |
| } | |
| export function decodeBuffer(buffer: ArrayBuffer, encoding?: string): string { | |
| const decoder = new TextDecoder(encoding) | |
| return decoder.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. | |
| */ | |
| export function toArrayBuffer(array: Uint8Array): ArrayBuffer { | |
| return array.buffer.slice( | |
| array.byteOffset, | |
| array.byteOffset + array.byteLength | |
| ) | |
| } | |