Asaf
Asaf
DDeno
Created by Asaf on 5/23/2024 in #help
Deno write large file
How can I convert this node code to Deno
import fs from 'node:fs';

function* largeArrayGenerator() {
for (let i = 0; i < 1e9; i++) {
yield i;
}
}

const writeStream = fs.createWriteStream('largeArray-node.txt');

for (const i of largeArrayGenerator()) {
const data = `${i}\n`;
if (!writeStream.write(data)) {
await new Promise(resolve => writeStream.once('drain', resolve));
}
}
import fs from 'node:fs';

function* largeArrayGenerator() {
for (let i = 0; i < 1e9; i++) {
yield i;
}
}

const writeStream = fs.createWriteStream('largeArray-node.txt');

for (const i of largeArrayGenerator()) {
const data = `${i}\n`;
if (!writeStream.write(data)) {
await new Promise(resolve => writeStream.once('drain', resolve));
}
}
how can I write large file in Deno and write only when the highWaterMark reached so I can apply draining?
8 replies
DDeno
Created by Asaf on 1/4/2024 in #help
deployctl error: TypeError: request or response body error
Hey, I'm getting an error when trying to deploy to a project error: TypeError: request or response body error: error reading a body from connection: stream error received: unexpected internal error encountered It stucks on ⠴ Deploying... (100.0%) and after sometime it throw the error I mentioned above I created new project and this is my file
import { emojify } from 'npm:node-emoji@2';

Deno.serve(() => new Response(emojify(':t-rex: :heart: NPM')));
import { emojify } from 'npm:node-emoji@2';

Deno.serve(() => new Response(emojify(':t-rex: :heart: NPM')));
It was working great yesterday, anyone can assist? I've noticing its not working whenever I specify a npm module import
4 replies