Skip to content

Latest commit

 

History

History
114 lines (72 loc) · 2.03 KB

DEMO.md

File metadata and controls

114 lines (72 loc) · 2.03 KB

Deno demo 🤟

Hello world demo

Prints "Hello world!".

From terminal:

console.log('Hello world!')

From URL:

deno run https://raw.githubusercontent.com/bolzon/deno-handson/main/samples/hello.ts

Demo:

Module cache: modules imported in deno are cached such as <script> tag in browser.

Fetch demo

Fetch remote content in different ways.

Access to network needs explicit permission (--allow-net).

deno run --allow-net <script>

Demos:

Http server demo

How to start a simple HTTP server.

No external modules needed; uses the Deno Standard Library.

Demo:

File read demo

Read a text file.

Access to read files needs explicit permission (--allow-read).

deno run --allow-read <script>

Demo:

File write demo

Write a text file.

Access to write files needs explicit permission (--allow-write).

deno run --allow-write <script>

Demo:

Compile scripts

Scripts can be compiled into a single executable file.

deno compile --unstable <OUT>

Built-in functionalities

Watcher

Deno has a built-in file watcher (like nodemon) to restart a script that was changed on disk.

deno run --watch --unstable --allow-net http-server.ts

Formatter

Deno has a built-in code formatter that auto formats TypeScript and JavaScript code.

deno fmt          # all files
deno fmt file.ts  # only file.ts

It's also possible just to check the file (diff) format instead of applying it by adding --check flag.

deno fmt --check  # checks format only

Linter

Deno has a built-in code linter for TypeScript and JavaScript.

deno lint --unstable          # all files
deno lint --unstable file.ts  # only file.ts