Spaces:
Paused
Paused
Download node_modules/fetch-event-stream/esm/utils.js from sam522/GenAI_Course: direct link, hf CLI and curl.
- Browser
- Download file 712 Bytes
-
https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/fetch-event-stream/esm/utils.js
- Command line
-
hf download hf://spaces/sam522/GenAI_Course@bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/fetch-event-stream/esm/utils.js
-
curl -L -o utils.js https://huggingface.co/spaces/sam522/GenAI_Course/resolve/bbf0eafbb40cb551e2f40f8ad8a90a585be08221/node_modules/fetch-event-stream/esm/utils.js
712 Bytes
| import { TextLineStream } from './deps/jsr.io/@std/streams/0.221.0/text_line_stream.js'; | |
| export function stream(input) { | |
| let decoder = new TextDecoderStream(); | |
| let split = new TextLineStream({ allowCR: true }); | |
| return input.pipeThrough(decoder).pipeThrough(split); | |
| } | |
| export function split(input) { | |
| let rgx = /[:]\s*/; | |
| let match = rgx.exec(input); | |
| // ": comment" -> index=0 -> ignore | |
| let idx = match && match.index; | |
| if (idx) { | |
| return [ | |
| input.substring(0, idx), | |
| input.substring(idx + match[0].length), | |
| ]; | |
| } | |
| } | |
| export function fallback(headers, key, value) { | |
| let tmp = headers.get(key); | |
| if (!tmp) | |
| headers.set(key, value); | |
| } | |