jcayzac
jcayzac
Explore posts from servers
DDeno
Created by jcayzac on 5/15/2024 in #help
shebang and no file extension: how do I turn Typescript on?
I have scripts with a #!/usr/bin/env deno run shebang, but they execute as javascript —adding types lead to parsing errors. Can I enable typescript with a command line parameter to deno run?
3 replies
DDeno
Created by jcayzac on 5/1/2024 in #help
Where has std/hash/sha3.ts gone?
Basically what the title says. This was removed from std/ at some point, but I can't find the current location of the module anymore (looking it up on deno.land returns nothing).
6 replies
DDeno
Created by jcayzac on 1/10/2024 in #help
How to build a Response object with the 'url' property set
Writing unit tests. Some functions parse Response objects. How do I create some where the url property isn't an empty string? Crafting statusText and headers to mimick a server response from a certain host doesn't seem to work.
4 replies
DDeno
Created by jcayzac on 1/9/2024 in #help
Does fetch() support upgrading the connection to a websocket?
What happens when fetch() gets the response
HTTP/1.1 101 Switching Protocols
connection: upgrade
upgrade: websocket
HTTP/1.1 101 Switching Protocols
connection: upgrade
upgrade: websocket
…? How to get the WebSocket object from there?
3 replies
DDeno
Created by jcayzac on 1/5/2024 in #help
std/http/setCookie doesn't work?
It seems to only support single cookies:
import * as cookies from "https://deno.land/[email protected]/http/cookie.ts"
var h = new Headers()

cookies.setCookie(h, {name: 'foo', value: 'FOO'})
// Headers { "set-cookie": "foo=FOO" }
// OK (works as expected)

cookies.setCookie(h, {name: 'bar', value: 'BAR'})
// Headers { "set-cookie": "bar=BAR" }
// Not OK: Cookie `foo` was deleted for some reason!

cookies.setCookie(h, [{name: 'x', value: 'X'}, {name: 'y', value: 'Y'}])
// Headers { "set-cookie": "bar=BAR" }
// Not OK: None of the cookies were set
import * as cookies from "https://deno.land/[email protected]/http/cookie.ts"
var h = new Headers()

cookies.setCookie(h, {name: 'foo', value: 'FOO'})
// Headers { "set-cookie": "foo=FOO" }
// OK (works as expected)

cookies.setCookie(h, {name: 'bar', value: 'BAR'})
// Headers { "set-cookie": "bar=BAR" }
// Not OK: Cookie `foo` was deleted for some reason!

cookies.setCookie(h, [{name: 'x', value: 'X'}, {name: 'y', value: 'Y'}])
// Headers { "set-cookie": "bar=BAR" }
// Not OK: None of the cookies were set
Also, it assumes the Headers object is a container for response headers. For request headers it the right header would be cookie:, not set-cookie:.
7 replies
DDeno
Created by jcayzac on 1/5/2024 in #help
Abort signals and node compatibility
No description
4 replies
DDeno
Created by jcayzac on 12/20/2023 in #help
assertThrows() limitations
assertThrows() seems to only filter on class name and message. Is there an assert function for checking whether code throws a DOMException with a specific name?
7 replies
DDeno
Created by jcayzac on 12/15/2023 in #help
Is there a way to get deno coverage information in a vscode lens?
If I run my tests with coverage enabled, can I get some visual feedback in vscode?
16 replies
DDeno
Created by jcayzac on 12/2/2023 in #help
deno.jsonc "unstable" format?
No description
9 replies
DDeno
Created by jcayzac on 11/25/2023 in #help
Using "imports" in deno.json doesn't work in VS.code
* deno 1.38.3 * vs.code 1.84.2 * denoland.vscode-deno 3.28.0 I got rid of my import map and moved the "imports" directly into deno.json, as supported since 1.30.0. Deno works fine, but the VS.code extension is now broken and complains about the missing import map on each of my local import { … } from "@/foo/bar.ts".
14 replies
DDeno
Created by jcayzac on 11/24/2023 in #help
Migrating from EventEmitter…
Hi! I've got some legacy code that depends on node:events 's EventEmitter class, specifically its once() method that returns a promise resolving the next time a specific event arrives, as well as removeAllListeners(). What would you suggest I use to get rid of that dependency? I can't use EventTarget since it doesn't let you drop all the registered listeners and doesn't support the once() scenario. Anything else?
5 replies
DDeno
Created by jcayzac on 11/15/2023 in #help
Most efficient way to broadcast messages globally across main script and workers?
I basically want a simple message bus that is global to all my workers + the main script, without relying on any dependency. Is there something more efficient, maybe using MessageChannel, than using postMessage() in workers to send things to the main script and iterate through all workers in the main script to postMessage() again on each worker?
20 replies
DDeno
Created by jcayzac on 7/14/2023 in #help
std/http/server: URI too long —how to avoid loading those?
Using https://deno.land/[email protected]/http/server.ts, is there a way to reject long URIs before they are loaded in memory? I have a middleware that responds with 414 URI Too Long when the URI length is > 8192, but this only saves me from the cost of parsing that thing —it's still already loaded in memory even if it's 1MB in size. How can I get the server to close the connection when the URI grows beyond 8k instead?
6 replies
DDeno
Created by jcayzac on 7/14/2023 in #help
Worker: TS2304 [ERROR]: Cannot find name 'postMessage'
When type-checking a worker script that uses the global postMessage() method, deno check gives a TS2304 [ERROR]: Cannot find name 'postMessage' error. Is there any workaround?
9 replies
DDeno
Created by jcayzac on 7/14/2023 in #help
How to recover from worker death? It terminates my main program…
In the error message handler, I replace the dead worker with a new one, but it kills my program either way. Full repro & log at https://gist.github.com/jcayzac/48ae8304a6b3c790353c52f98e242904 Thanks!
5 replies
DDeno
Created by jcayzac on 11/3/2022 in #help
FFI how to pass (or get) 128-bit bigints to (or from) Rust functions?
I want to pass bigints from Deno and get i128 or u128 in Rust. Do I have to use typed arrays for that?
4 replies
DDeno
Created by jcayzac on 10/8/2022 in #help
Is there a good dataframe library for deno?
I use the nodejs bindings for pola.rs for now but I'd like to move from nodejs to deno. This is my last blocker. Pola.rs is written in Rust. Would I have to wait for the wasm version of it?
1 replies