deno | A modern runtime for JavaScript and TypeScript
kandi X-RAY | deno Summary
kandi X-RAY | deno Summary
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of deno
deno Key Features
deno Examples and Code Snippets
import yargs from 'https://deno.land/x/yargs/deno.ts'
import { Arguments } from 'https://deno.land/x/yargs/deno-types.ts'
yargs(Deno.args)
.command('download ', 'download a list of files', (yargs: any) => {
return yargs.positional('files',
Community Discussions
Trending Discussions on deno
QUESTION
I'm using Deno to compile some TypeScript and then serve it as part of a web page, so that it is run on the browser side. I'm trying to use a canvas element on the client side, and for that I need types like CanvasRenderingContext2D
or CanvasGradient
, which are defined in lib.dom.d.ts, but they are not available: Deno compilation gives errors like TS2304 [ERROR]: Cannot find name 'CanvasRenderingContext2D'.
. (On the other hand, type Path2D
(defined in the same file) does not cause problems.)
Note: I know the types will exist in runtime when the code runs in the browser, but I want Deno to know about them in compile time.
I've tried including the .d.ts file somehow. Things I tried:
- specifying
"libs": ["deno.window", "esnext"]
etc. in the compiler options (in deno.json). - importing the type like this:
ANSWER
Answered 2022-Feb-23 at 22:01You need to configure Deno to use only DOM and ES types when type-checking your program. You can do this using the supported TypeScript compiler options in a Deno config file:
./deno.json
:
QUESTION
I've been giving some thought at what could be the best way to deal with a batch of heavy operations with Javascript and I came up with the following:
...ANSWER
Answered 2021-Dec-28 at 15:43In your code, just pushing the promises inside the array won't start a concurrency work, but the way you will resolve them that can be made in a concurrency way. In this for
loop, each item of the results
array will execute synchronously one after another without any concurrency execution and the performance will be very low.
The javascript provides a way to achieve this "concurrency" execution, using the all static method of the Promise
native class:
QUESTION
With top-level await accepted into ES2022, I wonder if it is save to assume that await import("./path/to/module")
has no timeout at all.
Here is what I’d like to do:
ANSWER
Answered 2021-Aug-07 at 17:46As far as I know, there is no timeout by default in async-await. There is the await-timeout package, for example, that is adding a timeout behavior. Example:
QUESTION
When I first studied TypeScript, I found that node.js doesn't execute TypeScript, so you need to install a TypeScript compiler that converts your TypeScript code into JavaScript.
I searched until I found ts-node
(TypeScript execution and REPL for node.js), but when I read the documentation I found that they do the same (here). Even deno
(A modern runtime for JavaScript and TypeScript), is doing the same (here).
So my question is: are there any engines to execute TypeScript code without converting it to JavaScript?
...ANSWER
Answered 2021-Nov-17 at 15:19No, TypeScript is not a "standalone" language in that sense. It is and always will be a superset of JavaScript. This is why the TypeScript Compiler is often referred to as a transpiler: it doesn't compile to a lower-level language. After tsc
has run its checks it transforms existing source to JavaScript by simply stripping out all the TypeScript constructs.
From the intro of the official TypeScript Handbook:
The goal of TypeScript is to be a static typechecker for JavaScript programs - in other words, a tool that runs before your code runs (static) and ensures that the types of the program are correct (typechecked).
So in order to execute TypeScript, you will always need a JavaScript engine. You could adapt an existing JavaScript engine (or build your own) to understand TypeScript as well, but still it would always first have to be an engine conforming to the ECMAScript specification.
Deno is no different. It has a built-in TypeScript Compiler, which is a copy of the official one. From the TypeScript chapter of the Deno manual.
At a high level, Deno converts TypeScript (as well as TSX and JSX) into JavaScript. It does this via a combination of the TypeScript compiler, which we build into Deno, and a Rust library called swc. When the code has been type checked and transformed, it is stored in a cache, ready for the next run without the need to convert it from its source to JavaScript again.
After transpilation, Deno runs the output JavaScript on Google's V8 Engine, the same engine used in NodeJS and Chrome.
QUESTION
I have done my first package for Deno, and then I publish it to deno.land/x/.
I would like to know if there is a way to Ignore some files and dires at the time of upload the package, example: [".github",".vim","test_deps.ts"].
Pretty much like .npmignore.
...ANSWER
Answered 2021-Sep-23 at 06:45There is not currently a way to ignore files, but if you'd like to only include certain files, you can organize them separately in a subdirectory of your repository, and use that option when publishing your module:
The subdirectory that you choose in this step will become the root of the module's file hierarchy.
QUESTION
I was learning about the this
keyword and how it means different things with regards to regular functions vs ES6 arrow functions and function expressions and I came across something odd when trying to run the following code in Chrome, Deno and Node. So I prepared following:
Example:
...ANSWER
Answered 2021-Sep-23 at 12:47Three different
this
behaviours for three different JS engines
That's a misleading way of putting it. You have three different JS environments, but they're all using the same engine.
I am befuddled by Node giving me
this = {}
.
That's not what it's giving you: this = [object global]
.
What you're not seeing in Node is var count
showing up as this.count
. One way you'd get that behavior (I don't know whether that's what Node is doing) is by wrapping the entire code in an IIFE. If you do:
QUESTION
Does Deno have a way to shim/polyfill Node.js modules?
That is, let's say I have a typescript file that's part of a Node.js project, and it looks something like this
...ANSWER
Answered 2021-Aug-25 at 02:51You can use https://deno.land/x/std/node. It provide some Node's built-in modules. For external modules, you can take a look at https://esm.sh (The syntax is https://esm.sh/
.
And if you want to use it like NodeJS environment, you can do the following:
QUESTION
ANSWER
Answered 2021-Jul-28 at 08:48The problem is not that they are relative specifiers, but that they are not fully qualified. From section 6.6 in the manual:
Can I use TypeScript not written for Deno?Maybe. That is the best answer, we are afraid. For lots of reasons, Deno has chosen to have fully qualified module specifiers. In part this is because it treats TypeScript as a first class language. Also, Deno uses explicit module resolution, with no magic. This is effectively the same way browsers themselves work, though they don't obviously support TypeScript directly. If the TypeScript modules use imports that don't have these design decisions in mind, they may not work under Deno.
Also, in recent versions of Deno (starting with 1.5), we have started to use a Rust library to do transformations of TypeScript to JavaScript in certain scenarios. Because of this, there are certain situations in TypeScript where type information is required, and therefore those are not supported under Deno. If you are using
tsc
as stand-alone, the setting to use is"isolatedModules"
and setting it totrue
to help ensure that your code can be properly handled by Deno.One of the ways to deal with the extension and the lack of Node.js non-standard resolution logic is to use import maps which would allow you to specify "packages" of bare specifiers which then Deno could resolve and load.
QUESTION
In Deno, I know that I can run a command like so:
...ANSWER
Answered 2021-Jul-12 at 05:26Use cwd
to specify a different path relative to your working directory (or use an absolute path).
QUESTION
When I create an empty project with Gradle Kotlin DSL, even without any modifications, it would prompt Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'. Check your module classpath for missing or conflicting dependencies
The project can run, but the syntax highlighting and autocompletion for build.gradle.kts
don't work.
- https://github.com/gradle/kotlin-dsl-samples/issues/1308
- Changing gradle executable to
gradle-kotlin-dsl-5.2-20190122225509+0000-all.zip
- Changing gradle executable to
- https://youtrack.jetbrains.com/issue/KT-38296
- Remove empty SDKs in Project structure dialog
- Invalidate caches and restart
- Reinstalling Java 11
brew install java11
- Switching to official oracle JDK 15
brew install oracle-jdk
- https://youtrack.jetbrains.com/issue/KT-41141
- Re-adding SDKs in the SDK menu
- Adding
/Kotlin/kotlinc/lib
to Kotlin SDK's classpath
- http://youtrack.jetbrains.com/issue/IDEA-245027
- Deleting the cache folder manually
ANSWER
Answered 2021-Jan-21 at 16:25Answer credit to @AlexeyBelkov - Answered here: https://youtrack.jetbrains.com/issue/KTIJ-893
The syntax highlighting feature worked after:
- Delete
~/.gradle/caches
- Delete
~/Library/Application\ Support/Library/JetBrains/IntelliJIdea2020.3
- Delete
/.gradle
- Delete
/.idea
- Start IDEA and reimport the project.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install deno
Try running a simple program:.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page