TangJieHao
TangJieHao
DDeno
Created by TangJieHao on 9/1/2024 in #help
WritableSteam not opening.
It looks like I may have found my solution. The reader doesn't actually know when the stream is done because its continious so I need to exit early.
async writeToStdin(data: string): Promise<void> {
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
await this.stdinWriter.ready;
await this.stdinWriter.write(encoded);
}

async readFromStdout(): Promise<string> {
let buffer = "";
const decoder = new TextDecoder();
while (true) {
const { value, done } = await this.stdoutReader.read();
if (done) {
return buffer.trim();
}
buffer += decoder.decode(value, { stream: true });
console.log(buffer);

if (buffer.endsWith("\n")) {
return buffer.trim();
}
}
}
async writeToStdin(data: string): Promise<void> {
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
await this.stdinWriter.ready;
await this.stdinWriter.write(encoded);
}

async readFromStdout(): Promise<string> {
let buffer = "";
const decoder = new TextDecoder();
while (true) {
const { value, done } = await this.stdoutReader.read();
if (done) {
return buffer.trim();
}
buffer += decoder.decode(value, { stream: true });
console.log(buffer);

if (buffer.endsWith("\n")) {
return buffer.trim();
}
}
}
3 replies
DDeno
Created by TangJieHao on 9/1/2024 in #help
WritableSteam not opening.
So if I put releaseLock at the end this seems to unlock the stdin however it still gives me the error that even though the stream isn't locked anymore writer wont write anymore
async writeToStdin(data: string): Promise<void> {
console.log("Writing to stdin");
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
console.log(this.stdin);
const writer = await this.stdin.getWriter();
console.log(writer);
await writer.write(encoded);
writer.close();
writer.releaseLock();
}
async writeToStdin(data: string): Promise<void> {
console.log("Writing to stdin");
const encoder = new TextEncoder();
const encoded = encoder.encode(data);
console.log(this.stdin);
const writer = await this.stdin.getWriter();
console.log(writer);
await writer.write(encoded);
writer.close();
writer.releaseLock();
}
Writing to stdin
WritableStream { locked: false }
WritableStreamDefaultWriter {
closed: Promise { undefined },
desiredSize: 0,
ready: Promise { undefined }
}
error: Uncaught (in promise) TypeError: The stream is closing or is closed.
await writer.write(encoded);
Writing to stdin
WritableStream { locked: false }
WritableStreamDefaultWriter {
closed: Promise { undefined },
desiredSize: 0,
ready: Promise { undefined }
}
error: Uncaught (in promise) TypeError: The stream is closing or is closed.
await writer.write(encoded);
3 replies
DDeno
Created by TangJieHao on 9/1/2024 in #help
dwm hot reload
or how would I go about making my own?
2 replies
DDeno
Created by kindly on 8/3/2024 in #help
Vue example doesn't work out of the box
Might need to manually import types
9 replies
DDeno
Created by kindly on 8/3/2024 in #help
Vue example doesn't work out of the box
Just to make sure it was done properly did you copy and paste
deno run --allow-read --allow-write --allow-env npm:create-vite-extra@latest
deno run --allow-read --allow-write --allow-env npm:create-vite-extra@latest
9 replies
DDeno
Created by 🎀𝔸ℕ𝔾𝔼𝕃 𝔻𝕆𝕃𝕃𝔽𝔸ℂ𝔼🎀🇵🇸 on 6/28/2024 in #help
Event Loop for a bot
6 replies