Spaces:
Paused
Paused
Download node_modules/@huggingface/hub/src/utils/sha256-node.ts from Leon4gr45/nova-header-nav: direct link, hf CLI and curl.
- Browser
- Download file 747 Bytes
-
https://huggingface.co/spaces/Leon4gr45/nova-header-nav/resolve/main/node_modules/%40huggingface/hub/src/utils/sha256-node.ts
- Command line
-
hf download hf://spaces/Leon4gr45/nova-header-nav/node_modules/@huggingface/hub/src/utils/sha256-node.ts
-
curl -L -o sha256-node.ts https://huggingface.co/spaces/Leon4gr45/nova-header-nav/resolve/main/node_modules/%40huggingface/hub/src/utils/sha256-node.ts
747 Bytes
| import { Readable } from "node:stream"; | |
| import type { ReadableStream } from "node:stream/web"; | |
| import { createHash } from "node:crypto"; | |
| export async function* sha256Node( | |
| buffer: ArrayBuffer | Blob, | |
| opts?: { | |
| abortSignal?: AbortSignal; | |
| }, | |
| ): AsyncGenerator<number, string> { | |
| const sha256Stream = createHash("sha256"); | |
| const size = buffer instanceof Blob ? buffer.size : buffer.byteLength; | |
| let done = 0; | |
| const readable = | |
| buffer instanceof Blob ? Readable.fromWeb(buffer.stream() as ReadableStream) : Readable.from(Buffer.from(buffer)); | |
| for await (const buffer of readable) { | |
| sha256Stream.update(buffer); | |
| done += buffer.length; | |
| yield done / size; | |
| opts?.abortSignal?.throwIfAborted(); | |
| } | |
| return sha256Stream.digest("hex"); | |
| } | |