Skip to content

mrgrain/deno-talk

Repository files navigation

Deno

https://deno.land/

Step 0 - Introduction

  • What is Deno
  • Background and history
  • Features
  • Installation
  • Contributors

Step 1 - Hello World

cd step1

deno run https://raw.githubusercontent.com/mrgrain/deno-talk/master/step1/welcome.ts

code welcome.ts

Step 2 - Basics

import { bold, cyan, italic, red } from "https://deno.land/std/fmt/colors.ts";
cd step2

deno run welcome.ts

deno
deno eval "console.log('hello world')"

Step 3 - Dev practices

IDEA support, Format, Test, Bash

cd step3

code --install-extension denoland.vscode-deno

deno info
deno lint welcome.ts
deno fmt welcome.ts
deno run some_test.ts

Bash Completions

cd step4

# bash
deno completions bash > /usr/local/etc/bash_completion.d/deno.bash
source /usr/local/etc/bash_completion.d/deno.bash

# zsh
mkdir ~/.oh-my-zsh/custom/plugins/deno
deno completions zsh > ~/.oh-my-zsh/custom/plugins/deno/_deno

Integrity checking

deno cache --lock=lock.json --lock-write welcome.ts
deno cache --lock=lock.json --reload welcome.ts
deno run --lock=lock.json --cached-only mod.ts

Step 4 - Distribution

Fetch, Bundle & Install

deno cache welcome.ts
deno run welcome.ts "Name"
deno cache -r welcome.ts

# Clean cache ~> this will change
deno info
rm -rf /path/to/DENO_DIR 

deno bundle welcome.ts welcome.js
deno run -r welcome.js "Name"

deno install welcome.ts
welcome "Name"

Publishing

git commit
git tag 1.2.3
git push origin 1.2.3

Step 5 - Permissions

See: https://deno.land/[email protected]/getting_started/permissions#permissions

cd step5
welcome(Deno.env.get("USER"));
deno run --allow-env welcome.ts
deno run --allow-env=USER welcome.ts
const greetings = JSON.parse(
  await Deno.readTextFile("./greetings.json"),
) as string[];
greetings.forEach(welcome);
deno run --allow-env=USER --allow-read welcome.ts
deno run --allow-env=USER --allow-read=greetings.json welcome.ts

deno install --allow-env=USER --allow-read=greetings.json welcome.ts
deno run --prompt welcome.ts

Step 6 - Standards

Fetch API & Top-level async await

deno run --allow-net fetch.ts

WebAssembly

deno run wasm.ts

Web Storage API

deno run --location=http://localhost memory.ts  
deno run --location=http://localhost memory.ts Momo
deno run --location=http://localhost memory.ts

Import Maps

deno run --import-map=import_map.json import.ts

About

Tutorial code for a talk on Deno

Resources

Stars

Watchers

Forks

Packages

No packages published