Download node_modules/@aws-sdk/node-http-handler/dist-es/readable.mock.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 680 Bytes
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/node-http-handler/dist-es/readable.mock.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@aws-sdk/node-http-handler/dist-es/readable.mock.js
-
curl -L -o readable.mock.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/node-http-handler/dist-es/readable.mock.js
680 Bytes
| import { Readable } from "stream"; | |
| export class ReadFromBuffers extends Readable { | |
| constructor(options) { | |
| super(options); | |
| this.numBuffersRead = 0; | |
| this.buffersToRead = options.buffers; | |
| this.errorAfter = typeof options.errorAfter === "number" ? options.errorAfter : -1; | |
| } | |
| _read() { | |
| if (this.errorAfter !== -1 && this.errorAfter === this.numBuffersRead) { | |
| this.emit("error", new Error("Mock Error")); | |
| return; | |
| } | |
| if (this.numBuffersRead >= this.buffersToRead.length) { | |
| return this.push(null); | |
| } | |
| return this.push(this.buffersToRead[this.numBuffersRead++]); | |
| } | |
| } | |