Spaces:
Runtime error
Runtime error
Download node_modules/engine.io-parser/build/cjs/encodePacket.browser.js from fffiloni/controlnet-animation-doodle: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/fffiloni/controlnet-animation-doodle/resolve/main/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js
- Command line
-
hf download hf://spaces/fffiloni/controlnet-animation-doodle/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js
-
curl -L -o encodePacket.browser.js https://huggingface.co/spaces/fffiloni/controlnet-animation-doodle/resolve/main/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js
1.52 kB
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| const commons_js_1 = require("./commons.js"); | |
| const withNativeBlob = typeof Blob === "function" || | |
| (typeof Blob !== "undefined" && | |
| Object.prototype.toString.call(Blob) === "[object BlobConstructor]"); | |
| const withNativeArrayBuffer = typeof ArrayBuffer === "function"; | |
| // ArrayBuffer.isView method is not defined in IE10 | |
| const isView = obj => { | |
| return typeof ArrayBuffer.isView === "function" | |
| ? ArrayBuffer.isView(obj) | |
| : obj && obj.buffer instanceof ArrayBuffer; | |
| }; | |
| const encodePacket = ({ type, data }, supportsBinary, callback) => { | |
| if (withNativeBlob && data instanceof Blob) { | |
| if (supportsBinary) { | |
| return callback(data); | |
| } | |
| else { | |
| return encodeBlobAsBase64(data, callback); | |
| } | |
| } | |
| else if (withNativeArrayBuffer && | |
| (data instanceof ArrayBuffer || isView(data))) { | |
| if (supportsBinary) { | |
| return callback(data); | |
| } | |
| else { | |
| return encodeBlobAsBase64(new Blob([data]), callback); | |
| } | |
| } | |
| // plain string | |
| return callback(commons_js_1.PACKET_TYPES[type] + (data || "")); | |
| }; | |
| const encodeBlobAsBase64 = (data, callback) => { | |
| const fileReader = new FileReader(); | |
| fileReader.onload = function () { | |
| const content = fileReader.result.split(",")[1]; | |
| callback("b" + (content || "")); | |
| }; | |
| return fileReader.readAsDataURL(data); | |
| }; | |
| exports.default = encodePacket; | |