Deno

D

Deno

Chat about Deno, a modern runtime for JavaScript and TypeScript.

Join

Removing cookie for basic logout

I seem to be losing my mind. My logout pathway used to work, but now no matter what method I use, the cookie remains and a) the cookie is never removed b) the user can't actually logout as a consequence ...

How to import enums from npm:typescript package?

The following code crashes because the enum is undefined at runtime.
import * as ts from "npm:typescript";
console.log(ts.ScriptTarget.ESNext);
import * as ts from "npm:typescript";
console.log(ts.ScriptTarget.ESNext);
...

type checking `.js` files using `d.ts` files

would it be possible to type check javascript files using d.ts files? ```js // add.js /// <reference types="./add.d.ts" /> const add = (a) => a + 1...

Which standard lib do I use?

I see the docs referencing https://deno.land/std/ But I thought JSR is the new shiny thing? And everythign is referencing jsr:@std. So which stnardard lib do I use?...

cannot execute: required file not found

Using termux Got this error after installation with
curl -fsSL https://deno.land/install.sh | sh
curl -fsSL https://deno.land/install.sh | sh
...

how to check if a promise has been resolved

@Deno AI Helper how to check if a promise has been resolved

Debug deno deploy failures ISOLATE_INTERNAL_FAILURE

how can you debug deno deploy failures? ``` cotyhamilton dev/no-build (main) ➜ deployctl deploy --project=no-build --entrypoint=mod.ts...

Data sync input between parent and children

I have the following scheme (cf picture): - a route that get initial data - data with items are sent to an island - item of data are sent to a child island ...

how to get WebSocketStream's current state?

how to get WebSocketStream's state like WebSocket.CLOSED WebSocket.OPEN etc

Does preact useSignal() values need to be cleared for memory leak?

In react, I often had to do a if (mounted.current) {...} test to do something with reactive variables like states if I'm setting/using it after a Promise. If I use useSignal() from Preact, do I still have to check for if (mounted.current) {...} ?...

Are there any up-to-date library for date and time in Deno?

Currently I working on personal project which needs an date and time library. I think about moment and date-fns firstly. After that I search for them and found out that they aren't updated at least three years. I just wonder about theirs security and trustfulness. Should I install one of them from npm because Deno is compatible with npm packages? Thanks...

Importing module is "not found" even though it obviously exists.

I have a new install of deno/fresh. running some deno task build reports an error when attempting to import the fresh.gen.ts file. ```sh error: Uncaught (in promise) TypeError: not found const manifest = (await import(toFileUrl(join(dir, "fresh.gen.ts")).href))...

How to properly publish a JSR package with browser compatibility?

I've been getting back to Deno and JS/TS development in general these last few days and I've been scratching my head over publication of a library I'm working on, I had in mind to publish it in a way it's easily available in Deno and in browsers, then I've stumbled upon JSR, but it marking packages as "browser compatible" is really confusing to me, especially when I can't seem to see any JS files in the published packages that are marked as browser compatible, is JSR not actually intended to be used directly in browser JS? Is there another CDN that I'm supposed to use to import JSR packages in browsers? So far my hunt for a good and easy solution seems to be failing, and I was getting my hopes up about not having to publish to npm and rely on npm-based JS CDNs....

Issue with Deno (Oak?)

<deleted context>
[uncaught application error]: Http - error writing a body to connection: received corrupt message of type InvalidContentType: received corrupt message of type InvalidContentType

at async HttpConn.nextRequest (ext:deno_http/01_http.js:114:21)
at async serve (https://deno.land/x/oak@v12.6.1/http_server_native.ts:112:34)
[uncaught application error]: Http - error writing a body to connection: received corrupt message of type InvalidContentType: received corrupt message of type InvalidContentType

at async HttpConn.nextRequest (ext:deno_http/01_http.js:114:21)
at async serve (https://deno.land/x/oak@v12.6.1/http_server_native.ts:112:34)
...

Custom body

I checked out the example for writing a simple HTTP server to only serve text at this link. How would I write a handler function that accepts a string parameter for the body content? Am I being stupid here?

Deno.serve: Is it possible to flush a streaming response?

I've been playing around with this: https://docs.deno.com/examples/http-server-streaming I am coming from Go and I'm used to having the functionality to flush the http response to the socket. Allowing lots of control over when bytes are sent over the wire (like so: https://robpike.io/) Is there any mechanism to prompt deno to write to the socket? Maybe another streaming response type?...

How to mock modules like you can with jest?

With node/jest I was able to mock specific functions from modules using jest.mock at the start of the test file. How can I do this in Deno? I have a module which calls a function from another module: ```ts import {foo} from "foo"; export function bar(a: number): number {...

Should I be using memo() in Fresh (/components/ folder)?

If Fresh renders the files in /components/ folder as html, and returns no javascript, should I ever bother using memo() in anything inside the components folder?

How to use new FormData constructor in Deno server, I want to use it for my supabase edge function.

I've created an edge function in supabase that requires formdata,I know it's a browser side thing and also supports in latest node version. But when I use this in deno , such as
const formData = require(form-data)
const formData = require(form-data)
it gives an error after deployment , it says require is not defined. But if I use
const formData = new FormData()
const formData = new FormData()
...
Next