D
Deno

help

extension method returning undefined for `text/plain`

Aadoublef8/10/2023
Given the following:
console.log(
"text/plain",
extension("text/plain"),
extensionsByType("text/plain"),
parseMediaType("text/plain"),
[...extensions.entries()]
);
console.log(
"text/plain",
extension("text/plain"),
extensionsByType("text/plain"),
parseMediaType("text/plain"),
[...extensions.entries()]
);
I seem to get the result
text/plain undefined undefined [ "text/plain", undefined ] []
text/plain undefined undefined [ "text/plain", undefined ] []
Am I missing something?
Mmarvinh.8/10/2023
Where are those functions extension, extensionsByType , etc coming from?
Aadoublef8/10/2023
stdlib https://deno.land/std@0.197.0/media_types/extensions_by_type.ts?s=extensionsByType
import { contentType } from "https://deno.land/std@0.198.0/media_types/content_type.ts";
import { extension } from "https://deno.land/std@0.198.0/media_types/extension.ts";
import { extensionsByType } from "https://deno.land/std@0.198.0/media_types/extensions_by_type.ts";
import { extensions } from "https://deno.land/std@0.198.0/media_types/_util.ts";
import { parseMediaType } from "https://deno.land/std@0.198.0/media_types/parse_media_type.ts";
import { contentType } from "https://deno.land/std@0.198.0/media_types/content_type.ts";
import { extension } from "https://deno.land/std@0.198.0/media_types/extension.ts";
import { extensionsByType } from "https://deno.land/std@0.198.0/media_types/extensions_by_type.ts";
import { extensions } from "https://deno.land/std@0.198.0/media_types/_util.ts";
import { parseMediaType } from "https://deno.land/std@0.198.0/media_types/parse_media_type.ts";
this is how I was importing them but looks like this was causing the error changing it to import from mod seems to have brought in the iife that populates the extenstion and types
import {
contentType,
extension,
extensionsByType,
extensions,
parseMediaType,
} from "https://deno.land/std@0.198.0/media_types/mod.ts";
import {
contentType,
extension,
extensionsByType,
extensions,
parseMediaType,
} from "https://deno.land/std@0.198.0/media_types/mod.ts";
I dunno, should I be allowed to just import the scripts i need without requiring to import mod.ts?
Mmarvinh.8/10/2023
I was mainly asking because the code snippet in the original message doesn't make it obvious where they are coming from. So when I copy & pasted the snippet it didn't find those functions This is the result I get on my end:
text/plain txt [
"txt", "text",
"conf", "def",
"list", "log",
"in", "ini"
] [ "text/plain", undefined ] [
[ "application/andrew-inset", [ "ez" ] ],
[ "application/applixware", [ "aw" ] ],
[ "application/atom+xml", [ "atom" ] ],
[ "application/atomcat+xml", [ "atomcat" ] ],
[ "application/atomdeleted+xml", [ "atomdeleted" ] ],
[ "application/atomsvc+xml", [ "atomsvc" ] ],
[ "application/atsc-dwd+xml", [ "dwd" ] ],
[ "application/atsc-held+xml", [ "held" ] ],
[ "application/atsc-rsat+xml", [ "rsat" ] ],
[ "application/bdoc", [ "bdoc" ] ]
...
]
text/plain txt [
"txt", "text",
"conf", "def",
"list", "log",
"in", "ini"
] [ "text/plain", undefined ] [
[ "application/andrew-inset", [ "ez" ] ],
[ "application/applixware", [ "aw" ] ],
[ "application/atom+xml", [ "atom" ] ],
[ "application/atomcat+xml", [ "atomcat" ] ],
[ "application/atomdeleted+xml", [ "atomdeleted" ] ],
[ "application/atomsvc+xml", [ "atomsvc" ] ],
[ "application/atsc-dwd+xml", [ "dwd" ] ],
[ "application/atsc-held+xml", [ "held" ] ],
[ "application/atsc-rsat+xml", [ "rsat" ] ],
[ "application/bdoc", [ "bdoc" ] ]
...
]
Aadoublef8/10/2023
ahhh nwnw, do you get those results when importing from mod.ts or from importing individual scripts (i.e media_types/extension.ts, media_types/content_type) @marvinh. thank you

Looking for more? Join the community!

Recommended Posts
Serving multiple static files to an HTTP requestIf a client sends a request for an array of static files names like so. ```["component01.js", "compoKv encodes integer as doubleAnyone know why Deno.kv encodes an integer in a mutli-part key as a double? ``` const key = ["int",Looking for caching API ResponsesHello there, I'm looking for a package/or examples to cache API responses for a fresh project whicUsing ZeroMQ from NPMAnyone got fixed the same error as this issue? https://github.com/denoland/deno/issues/18345Trying to pass parameters to runtime from rustHi, I'm launching a deno runtime from my project's code. I'm trying to pass some dynamic json variconsole.log in a worker - capture or hide output?Running under `deno repl` with no permissions, this prints 'yee'. In a browser's dev tools it would Deno debugging configuration is missing?```json "deno.enable": true, "deno.unstable": true, "deno.enablePaths": ["./api"], "deno.docIs there a way to show permissions used on start up during runtime?For example: If I was to run an App with `permissions: --allow-net=${hostname}:${port}` is there a wrestrict path applied for import mapshi, is it possible to restrict importmap application to only specific path? the rationale is: - vscoBest way to pass backend data to SSR rendered view?Looking for the "proper" way to pass data to an SSR rendered view. My first idea is setting custom pImport mapHi I have this in deno.json: ``` "imports": { "./app.controller": "./app.controller.ts", ``` butWhat should I specify to pass a "char *" in Deno.dlopen?For example, this is how you would use it in Python: ```python import ctypes lib = ctypes.cdll.LoadOverride NPM package dependencyRelating to my question yesterday (https://canary.discord.com/channels/684898665143206084/1137532072VS Code's debugger terminates before finishedI notice that occasionally the debugger terminates at the middle of the running, or at least doesn'tI need some guidance regarding interprocess communication with DenoWhat are good cross-platform (Windows, Linux) options for interprocess communication / data sharing What is the Deno class?What is Deno in Deno.cwd() ? Can someone link me to documentation? Why doesn't the Deno class need tGetIP + Ctx from middleware to a route not passedHi, I have test to retrieve IP visitor Code taken from Discord is always returning "localhost" (wheerror: No config file found in VS CodeI'm new in Deno and in coding, and need help with the following issue. I have installed Deno throughDeclaration merging for external packagesHi! I'm using unoCSS with Deno Fresh and have been attempting to use the attributify preset (https:Deno.serve AbortController onError. How?When I run my new Deno.serve() updated implementation I get a type error. Perhaps I'm doing it wrong