Deno Workshop

1st week

Software Engineer | Studio XID, Inc.

Microsoft MVP

Deno Korea User Group 4th member

TypeScript Korea User Group Organizer

Marktube (Youtube)

Mark Lee

  • Concept & Architecture, Getting Started, The Runtime, Runtime API, Tools, Testing, Deno Standard Modules, Examples, Third Party Modules

  • API Server Project

    • install mysql

    • nessie - A database migration tool for deno.

    • dex - An SQL query builder port of Knex for Deno

    • oak - A middleware framework for Deno's http server, including a router middleware.

    • denon - denon is the deno replacement for nodemon providing a feature packed and easy to use experience.

    • bcrypt - BCrypt support for hashing and checking passwords

    • djwt - The absolute minimum to make JSON Web Tokens on deno. Based on JWT and JWS specifications.

    • dotenv - Dotenv handling for deno.

no | de

 

de | no

JavaScript runtime built on

Chrome's V8 JavaScript engine.

2009

2018

A secure JavaScript/TypeScript runtime

built with V8, Rust, and Tokio

10 Things I Regret About Node.js

Ryan Dahl

JSConf EU 2018

2018.06

I Love TypeScript

regrets

  • Not sticking with Promises

    • Promises 를 밀었으면, 커뮤니티가 더 빨리 async / await 로 진보하지 않았을까

  • Security

    • 보안에 신경 쓰지 못한 것에 대한 후회

  • The Build System (GYP)

    • GYP => GN 으로 가지 못한 것과 FFI 를 제공하지 못한 것에 대한 후회

  • package.json

    • npm 에 의존하도록 만든 것과 불필요한 정보들까지 가져오는 것에 대한 후회

  • node_modules

    • 모듈을 가져오는 것이 어렵고, 브라우저에서 사용하는 방법과도 맞지 않아 어려워진 것에 대한 후회

  • require("module") without the extension ".js"

    • 브라우저에서의 표준과 달라서 모듈을 쓸때, 사용자의 의도를 파악하기 어려운 것에 대한 후회

  • index.js

    • index.html 을 따라했지만, 모듈 로딩 시스템이 더 복잡해짐

deno 설치하기

deno_install

https://github.com/denoland/deno_install

Deno is a single binary executable.

It has no external dependencies.

➜ curl -fsSL https://deno.land/x/install/install.sh | sh
######################################################################## 100.0%
Deno was installed successfully to /Users/mark/.deno/bin/deno
Manually add the directory to your $HOME/.bash_profile (or similar)
  export PATH="/Users/mark/.deno/bin:$PATH"
Run '/Users/mark/.deno/bin/deno --help' to get started

스크립트를 이용한 deno 런타임 설치

➜ curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0

스크립트를 이용한 "특정 버전의" deno 런타임 설치

$HOME/.deno/bin/deno

➜ /Users/mark/.deno/bin/deno --help

$HOME/.deno/bin/deno --help

# deno
export PATH="$HOME/.deno/bin:$PATH"

Add Environment PATH in .profile

➜ deno upgrade
Checking for latest version
Version has been found
Deno is upgrading to version 1.1.0
downloading https://github.com/denoland/deno/releases/download/v1.1.0/deno-x86_64-apple-darwin.zip
downloading https://github-production-release-asset-2e65be.s3.amazonaws.com/133442384/82737080-acd0-11ea-8397-c8f441f19bfa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200613T155009Z&X-Amz-Expires=300&X-Amz-Signature=dbe2eaad2e51bcbe2e88db96eefb40cec45b062ceb8476e6bfa7850f6531d7ef&X-Amz-SignedHeaders=host&actor_id=0&repo_id=133442384&response-content-disposition=attachment%3B%20filename%3Ddeno-x86_64-apple-darwin.zip&response-content-type=application%2Foctet-stream
Archive:  /var/folders/6j/z282xrxj1cl9hwjqkxnzsrs40000gn/T/.tmpxCXahR/deno.zip
  inflating: deno                    
Upgrade done successfully

deno 런타임 업그레이드

➜ deno upgrade --version 1.1.0
Version 1.1.0 is already installed

특정 버전으로 업그레이드 하기

➜ deno -V
deno 1.1.0

deno 런타임 버전 확인

➜ deno --help

deno 커맨드라인 명령어 사용법 확인

deno 커맨드라인 명령어

deno --help

SUBCOMMANDS:
    bundle         Bundle module and dependencies into single file
    cache          Cache the dependencies
    completions    Generate shell completions
    doc            Show documentation for a module
    eval           Eval script
    fmt            Format source files
    help           Prints this message or the help of the given subcommand(s)
    info           Show info about cache or info related to source file
    install        Install script as an executable
    lint           Lint source files
    repl           Read Eval Print Loop
    run            Run a program given a filename or url to the module. Use '-' as a filename to read from stdin.
    test           Run tests
    types          Print runtime TypeScript declarations
    upgrade        Upgrade deno executable to given version

SUBCOMMANDS

➜ deno help bundle

➜ deno bundle --help

SUBCOMMANDS : help

➜ deno help upgrade (deno upgrade --help)
deno-upgrade 
Upgrade deno executable to the given version.
Defaults to latest.

The version is downloaded from
https://github.com/denoland/deno/releases
and is used to replace the current executable.

USAGE:
    deno upgrade [OPTIONS]

OPTIONS:
        --dry-run                  Perform all checks without replacing old exe
    -f, --force                    Replace current exe even if not out-of-date
    -h, --help                     Prints help information
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output
        --version <version>        The version to upgrade to

SUBCOMMANDS : upgrade

➜ deno help repl
deno-repl 
Read Eval Print Loop

USAGE:
    deno repl [OPTIONS]

OPTIONS:
        --cert <FILE>                Load certificate authority from PEM encoded file
    -h, --help                       Prints help information
        --inspect=<HOST:PORT>        activate inspector on host:port (default: 127.0.0.1:9229)
        --inspect-brk=<HOST:PORT>    activate inspector on host:port and break at start of user script
    -L, --log-level <log-level>      Set log level [possible values: debug, info]
    -q, --quiet                      Suppress diagnostic output
        --unstable                   Enable unstable APIs
        --v8-flags=<v8-flags>        Set V8 command line options. For help: --v8-flags=--help

SUBCOMMANDS : repl

➜ deno repl     
Deno 1.1.0
exit using ctrl+d or close()
> console.log('Hello');
Hello
undefined
> const a = 38;
undefined
> console.log(a);
38
undefined
> type S = string;
Uncaught SyntaxError: Unexpected identifier
    at evaluate ($deno$/repl.ts:54:34)
    at Object.replLoop ($deno$/repl.ts:156:13)
> 

deno repl = deno

➜ deno help run 
deno-run 
Run a program given a filename or url to the module.

By default all programs are run in sandbox without access to disk, network or
ability to spawn subprocesses.
  deno run https://deno.land/std/examples/welcome.ts

Grant all permissions:
  deno run -A https://deno.land/std/http/file_server.ts

Grant permission to read from disk and listen to network:
  deno run --allow-read --allow-net https://deno.land/std/http/file_server.ts

Grant permission to read whitelisted files from disk:
  deno run --allow-read=/etc https://deno.land/std/http/file_server.ts
  
Deno allows specifying the filename '-' to read the file from stdin.
  curl https://deno.land/std/examples/welcome.ts | target/debug/deno run -

USAGE:
    deno run [OPTIONS] <SCRIPT_ARG>...

OPTIONS:
    -A, --allow-all                    Allow all permissions
        --allow-env                    Allow environment access
        --allow-hrtime                 Allow high resolution time measurement
        --allow-net=<allow-net>        Allow network access
        --allow-plugin                 Allow loading plugins
        --allow-read=<allow-read>      Allow file system read access
        --allow-run                    Allow running subprocesses
        --allow-write=<allow-write>    Allow file system write access
        --cached-only                  Require that remote dependencies are already cached
        --cert <FILE>                  Load certificate authority from PEM encoded file
    -c, --config <FILE>                Load tsconfig.json configuration file
    -h, --help                         Prints help information
        --importmap <FILE>             UNSTABLE: Load import map file
        --inspect=<HOST:PORT>          activate inspector on host:port (default: 127.0.0.1:9229)
        --inspect-brk=<HOST:PORT>      activate inspector on host:port and break at start of user script
        --lock <FILE>                  Check the specified lock file
        --lock-write                   Write lock file. Use with --lock.
    -L, --log-level <log-level>        Set log level [possible values: debug, info]
        --no-remote                    Do not resolve remote modules
    -q, --quiet                        Suppress diagnostic output
    -r, --reload=<CACHE_BLACKLIST>     Reload source code cache (recompile TypeScript)
        --seed <NUMBER>                Seed Math.random()
        --unstable                     Enable unstable APIs
        --v8-flags=<v8-flags>          Set V8 command line options. For help: --v8-flags=--help

ARGS:
    <SCRIPT_ARG>...    script args

SUBCOMMANDS : run

➜ deno help run 
deno-run 
Run a program given a filename or url to the module.

By default all programs are run in sandbox without access to disk, network or
ability to spawn subprocesses.
  deno run https://deno.land/std/examples/welcome.ts

Grant all permissions:
  deno run -A https://deno.land/std/http/file_server.ts

Grant permission to read from disk and listen to network:
  deno run --allow-read --allow-net https://deno.land/std/http/file_server.ts

Grant permission to read whitelisted files from disk:
  deno run --allow-read=/etc https://deno.land/std/http/file_server.ts
  
Deno allows specifying the filename '-' to read the file from stdin.
  curl https://deno.land/std/examples/welcome.ts | target/debug/deno run -

USAGE:
    deno run [OPTIONS] <SCRIPT_ARG>...

OPTIONS:
    -A, --allow-all                    Allow all permissions
        --allow-env                    Allow environment access
        --allow-hrtime                 Allow high resolution time measurement
        --allow-net=<allow-net>        Allow network access
        --allow-plugin                 Allow loading plugins
        --allow-read=<allow-read>      Allow file system read access
        --allow-run                    Allow running subprocesses
        --allow-write=<allow-write>    Allow file system write access
        --cached-only                  Require that remote dependencies are already cached
        --cert <FILE>                  Load certificate authority from PEM encoded file
    -c, --config <FILE>                Load tsconfig.json configuration file
    -h, --help                         Prints help information
        --importmap <FILE>             UNSTABLE: Load import map file
        --inspect=<HOST:PORT>          activate inspector on host:port (default: 127.0.0.1:9229)
        --inspect-brk=<HOST:PORT>      activate inspector on host:port and break at start of user script
        --lock <FILE>                  Check the specified lock file
        --lock-write                   Write lock file. Use with --lock.
    -L, --log-level <log-level>        Set log level [possible values: debug, info]
        --no-remote                    Do not resolve remote modules
    -q, --quiet                        Suppress diagnostic output
    -r, --reload=<CACHE_BLACKLIST>     Reload source code cache (recompile TypeScript)
        --seed <NUMBER>                Seed Math.random()
        --unstable                     Enable unstable APIs
        --v8-flags=<v8-flags>          Set V8 command line options. For help: --v8-flags=--help

ARGS:
    <SCRIPT_ARG>...    script args

deno run [ filename | url ]

deno run [ filename ]

~/Deno 
➜ echo "console.log('Hello Deno');" >> welcome.ts

~/Deno 
➜ cat welcome.ts 
console.log('Hello Deno');

~/Deno 
➜ deno run welcome.ts 
Compile file:///Users/mark/Deno/welcome.ts => 파일을 컴파일
Hello Deno => 실행

~/Deno 
➜ deno run ./welcome.ts
Hello Deno => 실행

~/Deno 
➜ deno run /Users/mark/Deno/welcome.ts            
Hello Deno => 실행

deno run [ url ]

~/Deno 
➜ deno run https://deno.land/std/examples/welcome.ts

Download https://deno.land/std/examples/welcome.ts => 파일을 다운로드
Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
=> 다운받은 url 이 명시적인 master branch 가 아님을 의미
Compile https://deno.land/std/examples/welcome.ts => 파일을 컴파일
Welcome to Deno 🦕 => 실행

~/Deno took 2s 
➜ deno run https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts
Download https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts => 파일을 다운로드
Compile https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts => 파일을 컴파일
Welcome to Deno 🦕 => 실행

~/Deno 
➜ deno run https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts
Welcome to Deno 🦕 => 실행

deno run -r [ filename ]

~/Deno 
➜ deno run -r welcome.ts            
Compile file:///Users/mark/Deno/welcome.ts => 파일을 다시 컴파일
Hello Deno => 실행

deno run -r [ url ]

~/Deno 
➜ deno run -r https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts

Download https://deno.land/std/examples/welcome.ts => 파일을 다시 다운로드
Compile https://deno.land/std/examples/welcome.ts => 파일을 다시 컴파일
Welcome to Deno 🦕 => 실행

SUBCOMMANDS : info (캐시 정보를 얻어내기)

~/Deno 
➜ deno info https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts
local: /Users/mark/Library/Caches/deno/deps/https/raw.githubusercontent.com/b4d51570d044a9e212325ea0df4614a665802a9a1e17256636d884301fa80597
type: TypeScript
compiled: /Users/mark/Library/Caches/deno/gen/https/raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts.js
map: /Users/mark/Library/Caches/deno/gen/https/raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts.js.map
deps:
https://raw.githubusercontent.com/denoland/deno/master/std/examples/welcome.ts

deno info 로 Default 캐시 폴더 확인하기

~/Deno 
➜ deno info                                     
DENO_DIR location: "/Users/mark/Library/Caches/deno"
Remote modules cache: "/Users/mark/Library/Caches/deno/deps"
TypeScript compiler cache: "/Users/mark/Library/Caches/deno/gen"

# help 를 이용해서 SUBCOMMAND info 사용법 확인

➜ deno help info
Without any additional arguments, 'deno info' shows:

DENO_DIR: Directory containing Deno-managed files.
Remote modules cache: Subdirectory containing downloaded remote modules.
TypeScript compiler cache: Subdirectory containing TS compiler output.

/Users/mark/Library/Caches/deno
+ /gen/https/deno.land/std/examples/welcome.ts.js

"use strict";
console.log("Welcome to Deno 🦕");
//# sourceMappingURL=file:///Users/mark/Library/Caches/deno/gen/https/deno.land/std/examples/welcome.ts.js.map

실행하지 않고 로컬 캐시로 가져와서 컴파일하기

~/Deno 
➜ deno cache https://deno.land/std/examples/welcome.ts

Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
Compile https://deno.land/std/examples/welcome.ts

~/Deno 
➜ deno cache https://deno.land/std/examples/welcome.ts

실행하지 않고 로컬 캐시로 다시 가져와서 다시 컴파일하기

~/Deno 
➜ deno cache -r https://deno.land/std/examples/welcome.ts

Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
Compile https://deno.land/std/examples/welcome.ts
➜ deno -r -c tsconfig.json welcome2.ts
[3/3] Compiling file:///Users/mark/deno/deno-is-coming/welcome2.ts
decorator1
Welcome to Deno 🦕

$DENO_DIR 과 -r (--reload)

https://github.com/denoland/deno/issues/1587

  • DENO_DIR 이 없으면,
    • ~/Library/Caches/deno
  • 있으면, 그 곳에
// .profile
export PATH="$HOME/.deno/bin:$PATH"
export DENO_DIR="$HOME/.deno"
➜ DENO_DIR=`pwd`/.deno deno -c tsconfig.json welcome2.ts
[2/2] Compiling file:///Users/mark/deno/deno-is-coming/welcome2.ts
decorator1
Welcome to Deno 🦕

SUBCOMMAND : bundle

➜ deno help bundle
deno-bundle 
Output a single JavaScript file with all dependencies.
  deno bundle https://deno.land/std/examples/colors.ts colors.bundle.js

If no output file is given, the output is written to standard output:
  deno bundle https://deno.land/std/examples/colors.ts

USAGE:
    deno bundle [OPTIONS] <source_file> [out_file]

OPTIONS:
        --cert <FILE>              Load certificate authority from PEM encoded file
    -c, --config <FILE>            Load tsconfig.json configuration file
    -h, --help                     Prints help information
        --importmap <FILE>         UNSTABLE: Load import map file
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output
        --unstable                 Enable unstable APIs

ARGS:
    <source_file>    
    <out_file> 

bundle 명령어를 통해 하나의 실행 파일로 만들기

~/Deno via ⬢ v12.16.3 
➜ deno bundle welcome.ts welcome.bundle.js
Bundling file:///Users/mark/Deno/welcome.ts
Emitting bundle to "welcome.bundle.js"
2.36 KB emitted.

~/Deno via ⬢ v12.16.3 
➜ deno run welcome.bundle.js 
Hello Deno

~/Deno via ⬢ v12.16.3 
➜ deno bundle https://deno.land/std/examples/welcome.ts welcome.bundle.js
Bundling https://deno.land/std/examples/welcome.ts
Emitting bundle to "welcome.bundle.js"
2.37 KB emitted.

~/Deno via ⬢ v12.16.3 
➜ deno run welcome.bundle.js                                             
Welcome to Deno 🦕

welcome-with-color.ts

import * as color from "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts";

console.log(color.yellow("Hello Deno"));
~/Deno via ⬢ v12.16.3 
➜ deno run welcome-with-color.ts
Download https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts
Compile file:///Users/mark/Deno/welcome-with-color.ts
Hello Deno

~/Deno via ⬢ v12.16.3 
➜ deno bundle welcome-with-color.ts welcome-with-color.bundle.js
Bundling file:///Users/mark/Deno/welcome-with-color.ts
Emitting bundle to "welcome-with-color.bundle.js"
9.42 KB emitted.

~/Deno via ⬢ v12.16.3 
➜ deno run welcome-with-color.bundle.js 
Hello Deno

bundle 명령어를 통해 하나의 실행 파일로 만들기 (사용되는 모듈 포함)

SUBCOMMAND : doc

➜ deno help doc
deno-doc 
Show documentation for a module.

Output documentation to standard output:
    deno doc ./path/to/module.ts

Output documentation in JSON format:
    deno doc --json ./path/to/module.ts

Target a specific symbol:
    deno doc ./path/to/module.ts MyClass.someField

Show documentation for runtime built-ins:
    deno doc
    deno doc --builtin Deno.Listener

USAGE:
    deno doc [OPTIONS] [ARGS]

OPTIONS:
    -h, --help                        Prints help information
        --json                        Output documentation in JSON format.
    -L, --log-level <log-level>       Set log level [possible values: debug, info]
    -q, --quiet                       Suppress diagnostic output
    -r, --reload=<CACHE_BLACKLIST>    Reload source code cache (recompile TypeScript)
        --unstable                    Enable unstable APIs

ARGS:
    <source_file>    
    <filter>         Dot separated path to symbol.

문서를 보는 용도 : deno doc [ filename | url ]

➜ deno doc https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts
function bgBlack(str: string): string

function bgBlue(str: string): string

function bgCyan(str: string): string

function bgGreen(str: string): string

function bgMagenta(str: string): string

function bgRed(str: string): string

function bgRgb24(str: string, color: number | Rgb): string
  Set background color using 24bit rgb. `color` can be a number in range `0x000000` to `0xffffff` or an `Rgb`.
  To produce the color magenta:
       bgRgba24("foo", 0xff00ff);      bgRgba24("foo", {r: 255, g: 0, b: 255});

function bgRgb8(str: string, color: number): string
  Set background color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

function bgWhite(str: string): string

function bgYellow(str: string): string

function black(str: string): string

function blue(str: string): string

function bold(str: string): string

function cyan(str: string): string

function dim(str: string): string

function getColorEnabled(): boolean

function gray(str: string): string

function green(str: string): string

function hidden(str: string): string

function inverse(str: string): string

function italic(str: string): string

function magenta(str: string): string

function red(str: string): string

function reset(str: string): string

function rgb24(str: string, color: number | Rgb): string
  Set text color using 24bit rgb. `color` can be a number in range `0x000000` to `0xffffff` or an `Rgb`.
  To produce the color magenta:
       rgba24("foo", 0xff00ff);      rgba24("foo", {r: 255, g: 0, b: 255});

function rgb8(str: string, color: number): string
  Set text color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

function setColorEnabled(value: boolean): void

function strikethrough(str: string): string

function stripColor(string: string): string

function underline(str: string): string

function white(str: string): string

function yellow(str: string): string

"Deno 파일은 module 혹은 main 으로 동작한다."

"doc 는 module 을 이해하기 위한 용도이다."

"doc 는 파일에서 export 한 모든 것들을 보여준다."

JSON 형태로 문서를 볼 수 있다. : deno doc --json [ filename | url ]

➜ deno doc --json https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts
[
  {
    "kind": "function",
    "name": "setColorEnabled",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 32,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "value",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "boolean",
            "kind": "keyword",
            "keyword": "boolean"
          }
        }
      ],
      "returnType": {
        "repr": "void",
        "kind": "keyword",
        "keyword": "void"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "getColorEnabled",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 40,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [],
      "returnType": {
        "repr": "boolean",
        "kind": "keyword",
        "keyword": "boolean"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "reset",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 58,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bold",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 62,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "dim",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 66,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "italic",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 70,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "underline",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 74,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "inverse",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 78,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "hidden",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 82,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "strikethrough",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 86,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "black",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 90,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "red",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 94,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "green",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 98,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "yellow",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 102,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "blue",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 106,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "magenta",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 110,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "cyan",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 114,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "white",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 118,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "gray",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 122,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgBlack",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 126,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgRed",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 130,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgGreen",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 134,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgYellow",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 138,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgBlue",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 142,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgMagenta",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 146,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgCyan",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 150,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgWhite",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 154,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "rgb8",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 166,
      "col": 0
    },
    "jsDoc": "Set text color using paletted 8bit colors.\nhttps://en.wikipedia.org/wiki/ANSI_escape_code#8-bit",
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        },
        {
          "name": "color",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "number",
            "kind": "keyword",
            "keyword": "number"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgRgb8",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 172,
      "col": 0
    },
    "jsDoc": "Set background color using paletted 8bit colors.\nhttps://en.wikipedia.org/wiki/ANSI_escape_code#8-bit",
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        },
        {
          "name": "color",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "number",
            "kind": "keyword",
            "keyword": "number"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "rgb24",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 185,
      "col": 0
    },
    "jsDoc": "Set text color using 24bit rgb.\n`color` can be a number in range `0x000000` to `0xffffff` or\nan `Rgb`.\n\nTo produce the color magenta:\n\n     rgba24(\"foo\", 0xff00ff);\n     rgba24(\"foo\", {r: 255, g: 0, b: 255});",
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        },
        {
          "name": "color",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "",
            "kind": "union",
            "union": [
              {
                "repr": "number",
                "kind": "keyword",
                "keyword": "number"
              },
              {
                "repr": "Rgb",
                "kind": "typeRef",
                "typeRef": {
                  "typeParams": null,
                  "typeName": "Rgb"
                }
              }
            ]
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "bgRgb24",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 216,
      "col": 0
    },
    "jsDoc": "Set background color using 24bit rgb.\n`color` can be a number in range `0x000000` to `0xffffff` or\nan `Rgb`.\n\nTo produce the color magenta:\n\n     bgRgba24(\"foo\", 0xff00ff);\n     bgRgba24(\"foo\", {r: 255, g: 0, b: 255});",
    "functionDef": {
      "params": [
        {
          "name": "str",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        },
        {
          "name": "color",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "",
            "kind": "union",
            "union": [
              {
                "repr": "number",
                "kind": "keyword",
                "keyword": "number"
              },
              {
                "repr": "Rgb",
                "kind": "typeRef",
                "typeRef": {
                  "typeParams": null,
                  "typeName": "Rgb"
                }
              }
            ]
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  },
  {
    "kind": "function",
    "name": "stripColor",
    "location": {
      "filename": "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts",
      "line": 247,
      "col": 0
    },
    "jsDoc": null,
    "functionDef": {
      "params": [
        {
          "name": "string",
          "kind": "identifier",
          "optional": false,
          "tsType": {
            "repr": "string",
            "kind": "keyword",
            "keyword": "string"
          }
        }
      ],
      "returnType": {
        "repr": "string",
        "kind": "keyword",
        "keyword": "string"
      },
      "isAsync": false,
      "isGenerator": false,
      "typeParams": []
    }
  }
]

이름으로 필터링해서 문서를 볼 수 있다. (1)

deno doc [ filename | url ] [ 검색 ]

➜ deno doc https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts yellow
Defined in https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts:102:0 

function yellow(str: string): string

Deno 런타임 API 보기

deno doc

➜ deno doc                        
function addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined): void

function atob(s: string): string

function btoa(s: string): string

function clearInterval(id?: number): void

function clearTimeout(id?: number): void

function dispatchEvent(event: Event): boolean

function fetch(input: Request | URL | string, init?: RequestInit): Promise<Response>

function queueMicrotask(func: Function): void

function removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined): void

function setInterval(cb: (args: any[]) => void, delay?: number, args: any[]): number

function setTimeout(cb: (args: any[]) => void, delay?: number, args: any[]): number

const AbortSignal: { prototype: AbortSignal }

const Blob: { prototype: Blob }

const File: { prototype: File }

const FormData: { prototype: FormData }

const Headers: { prototype: Headers }

var ReadableStream: { prototype: ReadableStream }

const Request: { prototype: Request }

const Response: { error(): Response, redirect(url: string, status?: number): Response, prototype: Response }

const URL: { createObjectURL(object: any): string, revokeObjectURL(url: string): void, prototype: URL }

const URLSearchParams: { toString(): string, prototype: URLSearchParams }

var console: Console

var crypto: Crypto

const isConsoleInstance: unique symbol

const onload: ((this: Window, ev: Event) => any) | null

const onunload: ((this: Window, ev: Event) => any) | null

const self: Window & typeof globalThis

const window: Window & typeof globalThis

class AbortController
  A controller object that allows you to abort one or more DOM requests as and when desired.

class ByteLengthQueuingStrategy implements QueuingStrategy

class Console

class CountQueuingStrategy implements QueuingStrategy
  This Streams API interface provides a built-in byte length queuing strategy that can be used when constructing streams.

class CustomEvent extends Event

class DOMException extends Error

class ErrorEvent extends Event

class Event
  An event which takes place in the DOM.

class EventTarget
  EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.

class MessageEvent extends Event

class TextDecoder

class TextEncoder

class TransformStream

class Worker extends EventTarget

class WritableStream
  This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.

interface Crypto

interface ImportMeta

interface Window extends EventTarget

type EventListenerOrEventListenerObject

namespace Deno

  function chdir(directory: string): void
    Change the current working directory to the specified path.
    ```ts Deno.chdir("/home/userA"); Deno.chdir("../userB"); Deno.chdir("C:\\Program Files (x86)\\Java"); ```
    Throws `Deno.errors.NotFound` if directory not found. Throws `Deno.errors.PermissionDenied` if the user does not have access rights
    Requires --allow-read.

  function chmod(path: string | URL, mode: number): Promise<void>
    Changes the permission of a specific file/directory of specified path. Ignores the process's umask.
    ```ts await Deno.chmod("/path/to/file", 0o666); ```
    The mode is a sequence of 3 octal numbers.  The first/left-most number specifies the permissions for the owner.  The second number specifies the permissions for the group. The last/right-most number specifies the permissions for others.  For example, with a mode of 0o764, the owner (7) can read/write/execute, the group (6) can read/write and everyone else (4) can read only.
    | Number | Description | | ------ | ----------- | | 7      | read, write, and execute | | 6      | read and write | | 5      | read and execute | | 4      | read only | | 3      | write and execute | | 2      | write only | | 1      | execute only | | 0      | no permission |
    NOTE: This API currently throws on Windows
    Requires `allow-write` permission.

  function chmodSync(path: string | URL, mode: number): void
    Synchronously changes the permission of a specific file/directory of specified path.  Ignores the process's umask.
    ```ts Deno.chmodSync("/path/to/file", 0o666); ```
    For a full description, see [chmod](#chmod)
    NOTE: This API currently throws on Windows
    Requires `allow-write` permission.

  function chown(path: string | URL, uid: number, gid: number): Promise<void>
    Change owner of a regular file or directory. This functionality is not available on Windows.
    ```ts await Deno.chown("myFile.txt", 1000, 1002); ```
    Requires `allow-write` permission.
    Throws Error (not implemented) if executed on Windows
    @param path path to the file @param uid user id (UID) of the new owner @param gid group id (GID) of the new owner

  function chownSync(path: string | URL, uid: number, gid: number): void
    Synchronously change owner of a regular file or directory. This functionality is not available on Windows.
    ```ts Deno.chownSync("myFile.txt", 1000, 1002); ```
    Requires `allow-write` permission.
    Throws Error (not implemented) if executed on Windows
    @param path path to the file @param uid user id (UID) of the new owner @param gid group id (GID) of the new owner

  function close(rid: number): void
    Close the given resource ID (rid) which has been previously opened, such as via opening or creating a file.  Closing a file when you are finished with it is important to avoid leaking resources.
    ```ts const file = await Deno.open("my_file.txt"); // do work with "file" object Deno.close(file.rid); ````

  function connect(options: ConnectOptions): Promise<Conn>
    Connects to the hostname (default is "127.0.0.1") and port on the named transport (default is "tcp"), and resolves to the connection (`Conn`).
    ```ts const conn1 = await Deno.connect({ port: 80 }); const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 }); const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 }); const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" }); ```
    Requires `allow-net` permission for "tcp".

  function connectTls(options: ConnectTlsOptions): Promise<Conn>
    Establishes a secure connection over TLS (transport layer security) using an optional cert file, hostname (default is "127.0.0.1") and port.  The cert file is optional and if not included Mozilla's root certificates will be used (see also https://github.com/ctz/webpki-roots for specifics)
    ```ts const conn1 = await Deno.connectTls({ port: 80 }); const conn2 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "192.0.2.1", port: 80 }); const conn3 = await Deno.connectTls({ hostname: "[2001:db8::1]", port: 80 }); const conn4 = await Deno.connectTls({ certFile: "./certs/my_custom_root_CA.pem", hostname: "golang.org", port: 80}); ```
    Requires `allow-net` permission.

  function copy(src: Reader, dst: Writer, options?: { bufSize: number }): Promise<number>
    Copies from `src` to `dst` until either EOF (`null`) is read from `src` or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.
    ```ts const source = await Deno.open("my_file.txt"); const buffer = new Deno.Buffer() const bytesCopied1 = await Deno.copy(source, Deno.stdout); const bytesCopied2 = await Deno.copy(source, buffer); ```
    @param src The source to copy from @param dst The destination to copy to @param options Can be used to tune size of the buffer. Default size is 32kB

  function copyFile(fromPath: string | URL, toPath: string | URL): Promise<void>
    Copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.
    ```ts await Deno.copyFile("from.txt", "to.txt"); ```
    Requires `allow-read` permission on fromPath. Requires `allow-write` permission on toPath.

  function copyFileSync(fromPath: string | URL, toPath: string | URL): void
    Synchronously copies the contents and permissions of one file to another specified path, by default creating a new file if needed, else overwriting. Fails if target path is a directory or is unwritable.
    ```ts Deno.copyFileSync("from.txt", "to.txt"); ```
    Requires `allow-read` permission on fromPath. Requires `allow-write` permission on toPath.

  function create(path: string | URL): Promise<File>
    Creates a file if none exists or truncates an existing file and resolves to  an instance of `Deno.File`.
    ```ts const file = await Deno.create("/foo/bar.txt"); ```
    Requires `allow-read` and `allow-write` permissions.

  function createSync(path: string | URL): File
    Creates a file if none exists or truncates an existing file and returns  an instance of `Deno.File`.
    ```ts const file = Deno.createSync("/foo/bar.txt"); ```
    Requires `allow-read` and `allow-write` permissions.

  function cwd(): string
    Return a string representing the current working directory.
    If the current directory can be reached via multiple paths (due to symbolic links), `cwd()` may return any one of them.
    ```ts const currentWorkingDirectory = Deno.cwd(); ```
    Throws `Deno.errors.NotFound` if directory not available.
    Requires --allow-read

  function execPath(): string
    Returns the path to the current deno executable.
    ```ts console.log(Deno.execPath());  // e.g. "/home/alice/.local/bin/deno" ```
    Requires `allow-read` permission.

  function exit(code?: number): never
    Exit the Deno process with optional exit code. If no exit code is supplied then Deno will exit with return code of 0.
    ```ts Deno.exit(5); ```

  function inspect(value: unknown, options?: InspectOptions): string
    Converts the input into a string that has the same format as printed by `console.log()`.
    ```ts const obj = {}; obj.propA = 10; obj.propB = "hello"; const objAsString = Deno.inspect(obj); // { propA: 10, propB: "hello" } console.log(obj);  // prints same value as objAsString, e.g. { propA: 10, propB: "hello" } ```
    You can also register custom inspect functions, via the `customInspect` Deno symbol on objects, to control and customize the output.
    ```ts class A {   x = 10;   y = "hello";   [Deno.customInspect](): string {     return "x=" + this.x + ", y=" + this.y;   } } ```
         const inStringFormat = Deno.inspect(new A()); // "x=10, y=hello"      console.log(inStringFormat);  // prints "x=10, y=hello"
    Finally, you can also specify the depth to which it will format.
         Deno.inspect({a: {b: {c: {d: 'hello'}}}}, {depth: 2}); // { a: { b: [Object] } }

  function isatty(rid: number): boolean
    Check if a given resource id (`rid`) is a TTY.
    ```ts // This example is system and context specific const nonTTYRid = Deno.openSync("my_file.txt").rid; const ttyRid = Deno.openSync("/dev/tty6").rid; console.log(Deno.isatty(nonTTYRid)); // false console.log(Deno.isatty(ttyRid)); // true Deno.close(nonTTYRid); Deno.close(ttyRid); ```

  function iter(r: Reader, options?: { bufSize: number }): AsyncIterableIterator<Uint8Array>
    Turns a Reader, `r`, into an async iterator.
    ```ts let f = await Deno.open("/etc/passwd"); for await (const chunk of Deno.iter(f)) {   console.log(chunk); } f.close(); ```
    Second argument can be used to tune size of a buffer. Default size of the buffer is 32kB.
    ```ts let f = await Deno.open("/etc/passwd"); const iter = Deno.iter(f, {   bufSize: 1024 * 1024 }); for await (const chunk of iter) {   console.log(chunk); } f.close(); ```
    Iterator uses an internal buffer of fixed size for efficiency; it returns a view on that buffer on each iteration. It is therefore caller's responsibility to copy contents of the buffer if needed; otherwise the next iteration will overwrite contents of previously returned chunk.

  function iterSync(r: ReaderSync, options?: { bufSize: number }): IterableIterator<Uint8Array>
    Turns a ReaderSync, `r`, into an iterator.
    ```ts let f = Deno.openSync("/etc/passwd"); for (const chunk of Deno.iterSync(f)) {   console.log(chunk); } f.close(); ```
    Second argument can be used to tune size of a buffer. Default size of the buffer is 32kB.
    ```ts let f = await Deno.open("/etc/passwd"); const iter = Deno.iterSync(f, {   bufSize: 1024 * 1024 }); for (const chunk of iter) {   console.log(chunk); } f.close(); ```
    Iterator uses an internal buffer of fixed size for efficiency; it returns a view on that buffer on each iteration. It is therefore caller's responsibility to copy contents of the buffer if needed; otherwise the next iteration will overwrite contents of previously returned chunk.

  function listen(options: ListenOptions & { transport: "tcp" }): Listener
    Listen announces on the local transport address.
    ```ts const listener1 = Deno.listen({ port: 80 }) const listener2 = Deno.listen({ hostname: "192.0.2.1", port: 80 }) const listener3 = Deno.listen({ hostname: "[2001:db8::1]", port: 80 }); const listener4 = Deno.listen({ hostname: "golang.org", port: 80, transport: "tcp" }); ```
    Requires `allow-net` permission.

  function listenTls(options: ListenTlsOptions): Listener
    Listen announces on the local transport address over TLS (transport layer security).
    ```ts const lstnr = Deno.listenTls({ port: 443, certFile: "./server.crt", keyFile: "./server.key" }); ```
    Requires `allow-net` permission.

  function lstat(path: string | URL): Promise<FileInfo>
    Resolves to a `Deno.FileInfo` for the specified `path`. If `path` is a symlink, information for the symlink will be returned instead of what it points to.
    ```ts import { assert } from "https://deno.land/std/testing/asserts.ts"; const fileInfo = await Deno.lstat("hello.txt"); assert(fileInfo.isFile); ```
    Requires `allow-read` permission.

  function lstatSync(path: string | URL): FileInfo
    Synchronously returns a `Deno.FileInfo` for the specified `path`. If `path` is a symlink, information for the symlink will be returned instead of what it points to..
    ```ts const fileInfo = Deno.lstatSync("hello.txt"); assert(fileInfo.isFile); ```
    Requires `allow-read` permission.

  function makeTempDir(options?: MakeTempOptions): Promise<string>
    Creates a new temporary directory in the default directory for temporary files (see also `Deno.dir("temp")`), unless `dir` is specified.  Other optional options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively.
    This call resolves to the full path to the newly created directory.
    Multiple programs calling this function simultaneously will create different directories. It is the caller's responsibility to remove the directory when no longer needed.
    ```ts const tempDirName0 = await Deno.makeTempDir();  // e.g. /tmp/2894ea76 const tempDirName1 = await Deno.makeTempDir({ prefix: 'my_temp' }); // e.g. /tmp/my_temp339c944d ```
    Requires `allow-write` permission.

  function makeTempDirSync(options?: MakeTempOptions): string
    Synchronously creates a new temporary directory in the default directory for temporary files (see also `Deno.dir("temp")`), unless `dir` is specified. Other optional options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively.
    The full path to the newly created directory is returned.
    Multiple programs calling this function simultaneously will create different directories. It is the caller's responsibility to remove the directory when no longer needed.
    ```ts const tempDirName0 = Deno.makeTempDirSync();  // e.g. /tmp/2894ea76 const tempDirName1 = Deno.makeTempDirSync({ prefix: 'my_temp' });  // e.g. /tmp/my_temp339c944d ```
    Requires `allow-write` permission.

  function makeTempFile(options?: MakeTempOptions): Promise<string>
    Creates a new temporary file in the default directory for temporary files (see also `Deno.dir("temp")`), unless `dir` is specified.  Other optional options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively.
    This call resolves to the full path to the newly created file.
    Multiple programs calling this function simultaneously will create different files. It is the caller's responsibility to remove the file when no longer needed.
    ```ts const tmpFileName0 = await Deno.makeTempFile();  // e.g. /tmp/419e0bf2 const tmpFileName1 = await Deno.makeTempFile({ prefix: 'my_temp' });  // e.g. /tmp/my_temp754d3098 ```
    Requires `allow-write` permission.

  function makeTempFileSync(options?: MakeTempOptions): string
    Synchronously creates a new temporary file in the default directory for temporary files (see also `Deno.dir("temp")`), unless `dir` is specified. Other optional options include prefixing and suffixing the directory name with `prefix` and `suffix` respectively.
    The full path to the newly created file is returned.
    Multiple programs calling this function simultaneously will create different files. It is the caller's responsibility to remove the file when no longer needed.
    ```ts const tempFileName0 = Deno.makeTempFileSync(); // e.g. /tmp/419e0bf2 const tempFileName1 = Deno.makeTempFileSync({ prefix: 'my_temp' });  // e.g. /tmp/my_temp754d3098 ```
    Requires `allow-write` permission.

  function metrics(): Metrics
    Receive metrics from the privileged side of Deno. This is primarily used in the development of Deno. 'Ops', also called 'bindings', are the go-between between Deno JavaScript and Deno Rust.
         > console.table(Deno.metrics())      ┌─────────────────────────┬────────┐      │         (index)         │ Values │      ├─────────────────────────┼────────┤      │      opsDispatched      │   3    │      │    opsDispatchedSync    │   2    │      │   opsDispatchedAsync    │   1    │      │ opsDispatchedAsyncUnref │   0    │      │      opsCompleted       │   3    │      │    opsCompletedSync     │   2    │      │    opsCompletedAsync    │   1    │      │ opsCompletedAsyncUnref  │   0    │      │    bytesSentControl     │   73   │      │      bytesSentData      │   0    │      │      bytesReceived      │  375   │      └─────────────────────────┴────────┘

  function mkdir(path: string | URL, options?: MkdirOptions): Promise<void>
    Creates a new directory with the specified path.
    ```ts await Deno.mkdir("new_dir"); await Deno.mkdir("nested/directories", { recursive: true }); await Deno.mkdir("restricted_access_dir", { mode: 0o700 }); ```
    Defaults to throwing error if the directory already exists.
    Requires `allow-write` permission.

  function mkdirSync(path: string | URL, options?: MkdirOptions): void
    Synchronously creates a new directory with the specified path.
    ```ts Deno.mkdirSync("new_dir"); Deno.mkdirSync("nested/directories", { recursive: true }); Deno.mkdirSync("restricted_access_dir", { mode: 0o700 }); ```
    Defaults to throwing error if the directory already exists.
    Requires `allow-write` permission.

  function open(path: string | URL, options?: OpenOptions): Promise<File>
    Open a file and resolve to an instance of `Deno.File`.  The file does not need to previously exist if using the `create` or `createNew` open options.  It is the callers responsibility to close the file when finished with it.
    ```ts const file = await Deno.open("/foo/bar.txt", { read: true, write: true }); // Do work with file Deno.close(file.rid); ```
    Requires `allow-read` and/or `allow-write` permissions depending on options.

  function openSync(path: string | URL, options?: OpenOptions): File
    Synchronously open a file and return an instance of `Deno.File`.  The file does not need to previously exist if using the `create` or `createNew` open options.  It is the callers responsibility to close the file when finished with it.
    ```ts const file = Deno.openSync("/foo/bar.txt", { read: true, write: true }); // Do work with file Deno.close(file.rid); ```
    Requires `allow-read` and/or `allow-write` permissions depending on options.

  function read(rid: number, buffer: Uint8Array): Promise<number | null>
    Read from a resource ID (`rid`) into an array buffer (`buffer`).
    Resolves to either the number of bytes read during the operation or EOF (`null`) if there was nothing more to read.
    It is possible for a read to successfully return with `0` bytes. This does not indicate EOF.
    This function is one of the lowest level APIs and most users should not work with this directly, but rather use Deno.readAll() instead.
    **It is not guaranteed that the full buffer will be read in a single call.**
    ```ts // if "/foo/bar.txt" contains the text "hello world": const file = await Deno.open("/foo/bar.txt"); const buf = new Uint8Array(100); const numberOfBytesRead = await Deno.read(file.rid, buf); // 11 bytes const text = new TextDecoder().decode(buf);  // "hello world" Deno.close(file.rid); ```

  function readAll(r: Reader): Promise<Uint8Array>
    Read Reader `r` until EOF (`null`) and resolve to the content as Uint8Array`.
    ```ts // Example from stdin const stdinContent = await Deno.readAll(Deno.stdin);
    // Example from file const file = await Deno.open("my_file.txt", {read: true}); const myFileContent = await Deno.readAll(file); Deno.close(file.rid);
    // Example from buffer const myData = new Uint8Array(100); // ... fill myData array with data const reader = new Deno.Buffer(myData.buffer as ArrayBuffer); const bufferContent = await Deno.readAll(reader); ```

  function readAllSync(r: ReaderSync): Uint8Array
    Synchronously reads Reader `r` until EOF (`null`) and returns the content as `Uint8Array`.
    ```ts // Example from stdin const stdinContent = Deno.readAllSync(Deno.stdin);
    // Example from file const file = Deno.openSync("my_file.txt", {read: true}); const myFileContent = Deno.readAllSync(file); Deno.close(file.rid);
    // Example from buffer const myData = new Uint8Array(100); // ... fill myData array with data const reader = new Deno.Buffer(myData.buffer as ArrayBuffer); const bufferContent = Deno.readAllSync(reader); ```

  function readDir(path: string | URL): AsyncIterable<DirEntry>
    Reads the directory given by `path` and returns an async iterable of `Deno.DirEntry`.
    ```ts for await (const dirEntry of Deno.readDir("/")) {   console.log(dirEntry.name); } ```
    Throws error if `path` is not a directory.
    Requires `allow-read` permission.

  function readDirSync(path: string | URL): Iterable<DirEntry>
    Synchronously reads the directory given by `path` and returns an iterable of `Deno.DirEntry`.
    ```ts for (const dirEntry of Deno.readDirSync("/")) {   console.log(dirEntry.name); } ```
    Throws error if `path` is not a directory.
    Requires `allow-read` permission.

  function readFile(path: string | URL): Promise<Uint8Array>
    Reads and resolves to the entire contents of a file as an array of bytes. `TextDecoder` can be used to transform the bytes to string if required. Reading a directory returns an empty data array.
    ```ts const decoder = new TextDecoder("utf-8"); const data = await Deno.readFile("hello.txt"); console.log(decoder.decode(data)); ```
    Requires `allow-read` permission.

  function readFileSync(path: string | URL): Uint8Array
    Synchronously reads and returns the entire contents of a file as an array of bytes. `TextDecoder` can be used to transform the bytes to string if required.  Reading a directory returns an empty data array.
    ```ts const decoder = new TextDecoder("utf-8"); const data = Deno.readFileSync("hello.txt"); console.log(decoder.decode(data)); ```
    Requires `allow-read` permission.

  function readLink(path: string): Promise<string>
    Resolves to the full path destination of the named symbolic link.
    ```ts await Deno.symlink("./test.txt", "./test_link.txt"); const target = await Deno.readLink("./test_link.txt"); // full path of ./test.txt ```
    Throws TypeError if called with a hard link
    Requires `allow-read` permission.

  function readLinkSync(path: string): string
    Returns the full path destination of the named symbolic link.
    ```ts Deno.symlinkSync("./test.txt", "./test_link.txt"); const target = Deno.readLinkSync("./test_link.txt"); // full path of ./test.txt ```
    Throws TypeError if called with a hard link
    Requires `allow-read` permission.

  function readSync(rid: number, buffer: Uint8Array): number | null
    Synchronously read from a resource ID (`rid`) into an array buffer (`buffer`).
    Returns either the number of bytes read during the operation or EOF (`null`) if there was nothing more to read.
    It is possible for a read to successfully return with `0` bytes. This does not indicate EOF.
    This function is one of the lowest level APIs and most users should not work with this directly, but rather use Deno.readAllSync() instead.
    **It is not guaranteed that the full buffer will be read in a single call.**
    ```ts // if "/foo/bar.txt" contains the text "hello world": const file = Deno.openSync("/foo/bar.txt"); const buf = new Uint8Array(100); const numberOfBytesRead = Deno.readSync(file.rid, buf); // 11 bytes const text = new TextDecoder().decode(buf);  // "hello world" Deno.close(file.rid); ```

  function readTextFile(path: string | URL): Promise<string>
    Asynchronously reads and returns the entire contents of a file as a utf8  encoded string. Reading a directory returns an empty data array.
    ```ts const data = await Deno.readTextFile("hello.txt"); console.log(data); ```
    Requires `allow-read` permission.

  function readTextFileSync(path: string | URL): string
    Synchronously reads and returns the entire contents of a file as utf8 encoded string  encoded string. Reading a directory returns an empty string.
    ```ts const data = Deno.readTextFileSync("hello.txt"); console.log(data); ```
    Requires `allow-read` permission.

  function realPath(path: string): Promise<string>
    Resolves to the absolute normalized path, with symbolic links resolved.
    ```ts // e.g. given /home/alice/file.txt and current directory /home/alice await Deno.symlink("file.txt", "symlink_file.txt"); const realPath = await Deno.realPath("./file.txt"); const realSymLinkPath = await Deno.realPath("./symlink_file.txt"); console.log(realPath);  // outputs "/home/alice/file.txt" console.log(realSymLinkPath);  // outputs "/home/alice/file.txt" ```
    Requires `allow-read` permission for the target path. Also requires `allow-read` permission for the CWD if the target path is relative.

  function realPathSync(path: string): string
    Returns absolute normalized path, with symbolic links resolved.
    ```ts // e.g. given /home/alice/file.txt and current directory /home/alice Deno.symlinkSync("file.txt", "symlink_file.txt"); const realPath = Deno.realPathSync("./file.txt"); const realSymLinkPath = Deno.realPathSync("./symlink_file.txt"); console.log(realPath);  // outputs "/home/alice/file.txt" console.log(realSymLinkPath);  // outputs "/home/alice/file.txt" ```
    Requires `allow-read` permission for the target path. Also requires `allow-read` permission for the CWD if the target path is relative.

  function remove(path: string | URL, options?: RemoveOptions): Promise<void>
    Removes the named file or directory.
    ```ts await Deno.remove("/path/to/empty_dir/or/file"); await Deno.remove("/path/to/populated_dir/or/file", { recursive: true }); ```
    Throws error if permission denied, path not found, or path is a non-empty directory and the `recursive` option isn't set to `true`.
    Requires `allow-write` permission.

  function removeSync(path: string | URL, options?: RemoveOptions): void
    Synchronously removes the named file or directory.
    ```ts Deno.removeSync("/path/to/empty_dir/or/file"); Deno.removeSync("/path/to/populated_dir/or/file", { recursive: true }); ```
    Throws error if permission denied, path not found, or path is a non-empty directory and the `recursive` option isn't set to `true`.
    Requires `allow-write` permission.

  function rename(oldpath: string, newpath: string): Promise<void>
    Renames (moves) `oldpath` to `newpath`.  Paths may be files or directories. If `newpath` already exists and is not a directory, `rename()` replaces it. OS-specific restrictions may apply when `oldpath` and `newpath` are in different directories.
    ```ts await Deno.rename("old/path", "new/path"); ```
    On Unix, this operation does not follow symlinks at either path.
    It varies between platforms when the operation throws errors, and if so what they are. It's always an error to rename anything to a non-empty directory.
    Requires `allow-read` and `allow-write` permission.

  function renameSync(oldpath: string, newpath: string): void
    Synchronously renames (moves) `oldpath` to `newpath`. Paths may be files or directories.  If `newpath` already exists and is not a directory, `renameSync()` replaces it. OS-specific restrictions may apply when `oldpath` and `newpath` are in different directories.
    ```ts Deno.renameSync("old/path", "new/path"); ```
    On Unix, this operation does not follow symlinks at either path.
    It varies between platforms when the operation throws errors, and if so what they are. It's always an error to rename anything to a non-empty directory.
    Requires `allow-read` and `allow-write` permissions.

  function resources(): ResourceMap
    Returns a map of open resource ids (rid) along with their string representations. This is an internal API and as such resource representation has `any` type; that means it can change any time.
    ```ts console.log(Deno.resources()); // { 0: "stdin", 1: "stdout", 2: "stderr" } Deno.openSync('../test.file'); console.log(Deno.resources()); // { 0: "stdin", 1: "stdout", 2: "stderr", 3: "fsFile" } ```

  function run(opt: T): Process<T>
    Spawns new subprocess.  RunOptions must contain at a minimum the `opt.cmd`, an array of program arguments, the first of which is the binary.
    ```ts const p = Deno.run({   cmd: ["echo", "hello"], }); ```
    Subprocess uses same working directory as parent process unless `opt.cwd` is specified.
    Environmental variables for subprocess can be specified using `opt.env` mapping.
    By default subprocess inherits stdio of parent process. To change that `opt.stdout`, `opt.stderr` and `opt.stdin` can be specified independently - they can be set to either an rid of open file or set to "inherit" "piped" or "null":
    `"inherit"` The default if unspecified. The child inherits from the corresponding parent descriptor.
    `"piped"` A new pipe should be arranged to connect the parent and child sub-processes.
    `"null"` This stream will be ignored. This is the equivalent of attaching the stream to `/dev/null`.
    Details of the spawned process are returned.
    Requires `allow-run` permission.

  function seek(rid: number, offset: number, whence: SeekMode): Promise<number>
    Seek a resource ID (`rid`) to the given `offset` under mode given by `whence`. The call resolves to the new position within the resource (bytes from the start).
    ```ts const file = await Deno.open('hello.txt', {read: true, write: true, truncate: true, create: true}); await Deno.write(file.rid, new TextEncoder().encode("Hello world")); // advance cursor 6 bytes const cursorPosition = await Deno.seek(file.rid, 6, Deno.SeekMode.Start); console.log(cursorPosition);  // 6 const buf = new Uint8Array(100); await file.read(buf); console.log(new TextDecoder().decode(buf)); // "world" ```
    The seek modes work as follows:
    ```ts // Given file.rid pointing to file with "Hello world", which is 11 bytes long: // Seek 6 bytes from the start of the file console.log(await Deno.seek(file.rid, 6, Deno.SeekMode.Start)); // "6" // Seek 2 more bytes from the current position console.log(await Deno.seek(file.rid, 2, Deno.SeekMode.Current)); // "8" // Seek backwards 2 bytes from the end of the file console.log(await Deno.seek(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2) ```

  function seekSync(rid: number, offset: number, whence: SeekMode): number
    Synchronously seek a resource ID (`rid`) to the given `offset` under mode given by `whence`.  The new position within the resource (bytes from the start) is returned.
    ```ts const file = Deno.openSync('hello.txt', {read: true, write: true, truncate: true, create: true}); Deno.writeSync(file.rid, new TextEncoder().encode("Hello world")); // advance cursor 6 bytes const cursorPosition = Deno.seekSync(file.rid, 6, Deno.SeekMode.Start); console.log(cursorPosition);  // 6 const buf = new Uint8Array(100); file.readSync(buf); console.log(new TextDecoder().decode(buf)); // "world" ```
    The seek modes work as follows:
    ```ts // Given file.rid pointing to file with "Hello world", which is 11 bytes long: // Seek 6 bytes from the start of the file console.log(Deno.seekSync(file.rid, 6, Deno.SeekMode.Start)); // "6" // Seek 2 more bytes from the current position console.log(Deno.seekSync(file.rid, 2, Deno.SeekMode.Current)); // "8" // Seek backwards 2 bytes from the end of the file console.log(Deno.seekSync(file.rid, -2, Deno.SeekMode.End)); // "9" (e.g. 11-2) ```

  function stat(path: string | URL): Promise<FileInfo>
    Resolves to a `Deno.FileInfo` for the specified `path`. Will always follow symlinks.
    ```ts import { assert } from "https://deno.land/std/testing/asserts.ts"; const fileInfo = await Deno.stat("hello.txt"); assert(fileInfo.isFile); ```
    Requires `allow-read` permission.

  function statSync(path: string | URL): FileInfo
    Synchronously returns a `Deno.FileInfo` for the specified `path`. Will always follow symlinks.
    ```ts import { assert } from "https://deno.land/std/testing/asserts.ts"; const fileInfo = Deno.statSync("hello.txt"); assert(fileInfo.isFile); ```
    Requires `allow-read` permission.

  function test(t: TestDefinition): void
    Register a test which will be run when `deno test` is used on the command line and the containing module looks like a test module. `fn` can be async if required. ```ts import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
    Deno.test({   name: "example test",   fn(): void {     assertEquals("world", "world");   }, });
    Deno.test({   name: "example ignored test",   ignore: Deno.build.os === "windows",   fn(): void {     // This test is ignored only on Windows machines   }, });
    Deno.test({   name: "example async test",   async fn() {     const decoder = new TextDecoder("utf-8");     const data = await Deno.readFile("hello_world.txt");     assertEquals(decoder.decode(data), "Hello world");   } }); ```

  function test(name: string, fn: () => void | Promise<void>): void
    Register a test which will be run when `deno test` is used on the command line and the containing module looks like a test module. `fn` can be async if required.
    ```ts import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts";
    Deno.test("My test description", ():void => {   assertEquals("hello", "hello"); });
    Deno.test("My async test description", async ():Promise<void> => {   const decoder = new TextDecoder("utf-8");   const data = await Deno.readFile("hello_world.txt");   assertEquals(decoder.decode(data), "Hello world"); }); ```

  function truncate(name: string, len?: number): Promise<void>
    Truncates or extends the specified file, to reach the specified `len`. If `len` is not specified then the entire file contents are truncated.
    ```ts // truncate the entire file await Deno.truncate("my_file.txt");
    // truncate part of the file const file = await Deno.makeTempFile(); await Deno.writeFile(file, new TextEncoder().encode("Hello World")); await Deno.truncate(file, 7); const data = await Deno.readFile(file); console.log(new TextDecoder().decode(data));  // "Hello W" ```
    Requires `allow-write` permission.

  function truncateSync(name: string, len?: number): void
    Synchronously truncates or extends the specified file, to reach the specified `len`.  If `len` is not specified then the entire file contents are truncated.
    ```ts // truncate the entire file Deno.truncateSync("my_file.txt");
    // truncate part of the file const file = Deno.makeTempFileSync(); Deno.writeFileSync(file, new TextEncoder().encode("Hello World")); Deno.truncateSync(file, 7); const data = Deno.readFileSync(file); console.log(new TextDecoder().decode(data)); ```
    Requires `allow-write` permission.

  function watchFs(paths: string | string[], options?: { recursive: boolean }): AsyncIterableIterator<FsEvent>
    Watch for file system events against one or more `paths`, which can be files or directories.  These paths must exist already.  One user action (e.g. `touch test.file`) can  generate multiple file system events.  Likewise, one user action can result in multiple file paths in one event (e.g. `mv old_name.txt new_name.txt`).  Recursive option is `true` by default and, for directories, will watch the specified directory and all sub directories. Note that the exact ordering of the events can vary between operating systems.
    ```ts const watcher = Deno.watchFs("/"); for await (const event of watcher) {    console.log(">>>> event", event);    // { kind: "create", paths: [ "/foo.txt" ] } } ```
    Requires `allow-read` permission.

  function write(rid: number, data: Uint8Array): Promise<number>
    Write to the resource ID (`rid`) the contents of the array buffer (`data`).
    Resolves to the number of bytes written.  This function is one of the lowest level APIs and most users should not work with this directly, but rather use Deno.writeAll() instead.
    **It is not guaranteed that the full buffer will be written in a single call.**
    ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world"); const file = await Deno.open("/foo/bar.txt", { write: true }); const bytesWritten = await Deno.write(file.rid, data); // 11 Deno.close(file.rid); ```

  function writeAll(w: Writer, arr: Uint8Array): Promise<void>
    Write all the content of the array buffer (`arr`) to the writer (`w`).
    ```ts // Example writing to stdout const contentBytes = new TextEncoder().encode("Hello World"); await Deno.writeAll(Deno.stdout, contentBytes);
    // Example writing to file const contentBytes = new TextEncoder().encode("Hello World"); const file = await Deno.open('test.file', {write: true}); await Deno.writeAll(file, contentBytes); Deno.close(file.rid);
    // Example writing to buffer const contentBytes = new TextEncoder().encode("Hello World"); const writer = new Deno.Buffer(); await Deno.writeAll(writer, contentBytes); console.log(writer.bytes().length);  // 11 ```

  function writeAllSync(w: WriterSync, arr: Uint8Array): void
    Synchronously write all the content of the array buffer (`arr`) to the writer (`w`).
    ```ts // Example writing to stdout const contentBytes = new TextEncoder().encode("Hello World"); Deno.writeAllSync(Deno.stdout, contentBytes);
    // Example writing to file const contentBytes = new TextEncoder().encode("Hello World"); const file = Deno.openSync('test.file', {write: true}); Deno.writeAllSync(file, contentBytes); Deno.close(file.rid);
    // Example writing to buffer const contentBytes = new TextEncoder().encode("Hello World"); const writer = new Deno.Buffer(); Deno.writeAllSync(writer, contentBytes); console.log(writer.bytes().length);  // 11 ```

  function writeFile(path: string | URL, data: Uint8Array, options?: WriteFileOptions): Promise<void>
    Write `data` to the given `path`, by default creating a new file if needed, else overwriting.
    ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world\n"); await Deno.writeFile("hello1.txt", data);  // overwrite "hello1.txt" or create it await Deno.writeFile("hello2.txt", data, {create: false});  // only works if "hello2.txt" exists await Deno.writeFile("hello3.txt", data, {mode: 0o777});  // set permissions on new file await Deno.writeFile("hello4.txt", data, {append: true});  // add data to the end of the file ```
    Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.

  function writeFileSync(path: string | URL, data: Uint8Array, options?: WriteFileOptions): void
    Synchronously write `data` to the given `path`, by default creating a new file if needed, else overwriting.
    ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world\n"); Deno.writeFileSync("hello1.txt", data);  // overwrite "hello1.txt" or create it Deno.writeFileSync("hello2.txt", data, {create: false});  // only works if "hello2.txt" exists Deno.writeFileSync("hello3.txt", data, {mode: 0o777});  // set permissions on new file Deno.writeFileSync("hello4.txt", data, {append: true});  // add data to the end of the file ```
    Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.

  function writeSync(rid: number, data: Uint8Array): number
    Synchronously write to the resource ID (`rid`) the contents of the array buffer (`data`).
    Returns the number of bytes written.  This function is one of the lowest level APIs and most users should not work with this directly, but rather use Deno.writeAllSync() instead.
    **It is not guaranteed that the full buffer will be written in a single call.**
    ```ts const encoder = new TextEncoder(); const data = encoder.encode("Hello world"); const file = Deno.openSync("/foo/bar.txt", {write: true}); const bytesWritten = Deno.writeSync(file.rid, data); // 11 Deno.close(file.rid); ```

  function writeTextFile(path: string | URL, data: string): Promise<void>
    Asynchronously write string `data` to the given `path`, by default creating a new file if needed, else overwriting.
    ```ts await Deno.writeTextFile("hello1.txt", "Hello world\n");  // overwrite "hello1.txt" or create it ```
    Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.

  function writeTextFileSync(path: string | URL, data: string): void
    Synchronously write string `data` to the given `path`, by default creating a new file if needed, else overwriting.
    ```ts await Deno.writeTextFileSync("hello1.txt", "Hello world\n");  // overwrite "hello1.txt" or create it ```
    Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.

  const args: string[]
    Returns the script arguments to the program. If for example we run a program:
    deno run --allow-read https://deno.land/std/examples/cat.ts /etc/passwd
    Then `Deno.args` will contain:
    [ "/etc/passwd" ]

  const build: { target: string, arch: "x86_64", os: "darwin" | "linux" | "windows", vendor: string, env: string }
    Build related information.

  const customInspect: unique symbol
    A symbol which can be used as a key for a custom method which will be called when `Deno.inspect()` is called, or when the object is logged to the console.

  const env: { get(key: string): string | undefined, set(key: string, value: string): void, delete(key: string): void, toObject(): {  } }

  const errors: { NotFound: ErrorConstructor, PermissionDenied: ErrorConstructor, ConnectionRefused: ErrorConstructor, ConnectionReset: ErrorConstructor, ConnectionAborted: ErrorConstructor, NotConnected: ErrorConstructor, AddrInUse: ErrorConstructor, AddrNotAvailable: ErrorConstructor, BrokenPipe: ErrorConstructor, AlreadyExists: ErrorConstructor, InvalidData: ErrorConstructor, TimedOut: ErrorConstructor, Interrupted: ErrorConstructor, WriteZero: ErrorConstructor, UnexpectedEof: ErrorConstructor, BadResource: ErrorConstructor, Http: ErrorConstructor, Busy: ErrorConstructor }
    A set of error constructors that are raised by Deno APIs.

  const noColor: boolean
    Reflects the `NO_COLOR` environment variable.
    See: https://no-color.org/

  const pid: number
    The current process id of the runtime.

  const stderr: Writer & WriterSync & Closer & { rid: number }
    A handle for `stderr`.

  const stdin: Reader & ReaderSync & Closer & { rid: number }
    A handle for `stdin`.

  const stdout: Writer & WriterSync & Closer & { rid: number }
    A handle for `stdout`.

  const version: Version
    Version related information.

  class Buffer implements Reader, ReaderSync, Writer, WriterSync
    A variable-sized buffer of bytes with `read()` and `write()` methods.
    Deno.Buffer is almost always used with some I/O like files and sockets. It allows one to buffer up a download from a socket. Buffer grows and shrinks as necessary.
    Deno.Buffer is NOT the same thing as Node's Buffer. Node's Buffer was created in 2009 before JavaScript had the concept of ArrayBuffers. It's simply a non-standard ArrayBuffer.
    ArrayBuffer is a fixed memory allocation. Deno.Buffer is implemented on top of ArrayBuffer.
    Based on [Go Buffer](https://golang.org/pkg/bytes/#Buffer).

  class File implements Reader, ReaderSync, Writer, WriterSync, Seeker, SeekerSync, Closer
    The Deno abstraction for reading and writing files.

  class Process

  enum SeekMode

  interface Closer

  interface Conn extends Reader, Writer, Closer

  interface ConnectOptions

  interface ConnectTlsOptions

  interface DirEntry

  interface FileInfo
    A FileInfo describes a file and is returned by `stat`, `lstat`, `statSync`, `lstatSync`.

  interface FsEvent

  interface ListenOptions

  interface ListenTlsOptions extends ListenOptions

  interface Listener extends AsyncIterable
    A generic network listener for stream-oriented protocols.

  interface MakeTempOptions

  interface Metrics

  interface MkdirOptions

  interface NetAddr

  interface OpenOptions

  interface Reader

  interface ReaderSync

  interface RemoveOptions

  interface RunOptions

  interface Seeker

  interface SeekerSync

  interface TestDefinition

  interface UnixAddr

  interface WriteFileOptions
    Options for writing to a file.

  interface Writer

  interface WriterSync

  type Addr

  type ProcessStatus


namespace WebAssembly


namespace performance

  function now(): number
    Returns a current time from Deno's start in milliseconds.
    Use the permission flag `--allow-hrtime` return a precise value.
    ```ts const t = performance.now(); console.log(`${t} ms since start!`); ```

이름으로 필터링해서 문서를 볼 수 있다. (2)

deno doc --builtin [ 검색 ]

➜ deno doc --builtin performance
Defined in lib.deno.d.ts:3286:0 

namespace performance

  function now(): number

. 이름으로 내부로 찾아서 문서를 볼 수 있다. (3)

deno doc --builtin [ 검색 ]

➜ deno doc --builtin performance.now 
Defined in lib.deno.d.ts:3296:2 

function now(): number
    Returns a current time from Deno's start in milliseconds.
    Use the permission flag `--allow-hrtime` return a precise value.
    ```ts const t = performance.now(); console.log(`${t} ms since start!`); ```

"그럼 다른 개발자가 doc 를 사용해서
내 module 을 이해하기 위해
어떻게 파일을 작성해야 할까요 ?"

MyModule.ts

export interface Person {
  name: string;
  age: number;
}

/**
 * 이름을 부르며 인사를 합니다.
 * @param {Person} person
 * @returns {void}
 */
export function hello(person: Person): void {
  console.log(`hello, ${person.name}`);
}

/**
 * 이 상수는 그냥 쓴 상수 입니다.
 */
export const HELLO = "World";

/**
 * 이 클래스는 default 로 내보내기 되어 있습니다.
 * 멤버 변수와 함수는 전체 문서에는 안나옵니다.
 */
export default class MyClass {
  foo: number;
  bar() {}
}

/**
 * namespace 의 경우에는 . 을 이용해서 안의 내용을 검색할 수 있습니다.
 * Namespace.Klass
 */
export namespace Namespace {
  /**
   * 안쪽의 문서도 밖에서 보입니다.
   */
  export class Klass {}
}

deno doc MyModule.ts

➜ deno doc MyModule.ts

function hello(person: Person): void
  이름을 부르며 인사를 합니다. @param {Person} person @returns {void}

const HELLO
  이 상수는 그냥 쓴 상수 입니다.

class default
  이 클래스는 default 로 내보내기 되어 있습니다. 멤버 변수와 함수는 전체 문서에는 안나옵니다.

interface Person

namespace Namespace
  namespace 의 경우에는 . 을 이용해서 안의 내용을 검색할 수 있습니다. Namespace.Klass

  class Klass
    안쪽의 문서도 밖에서 보입니다.

deno doc MyModule.ts hello

➜ deno doc MyModule.ts hello

Defined in file:///Users/mark/Deno/MyModule.ts:11:0 

function hello(person: Person): void
    이름을 부르며 인사를 합니다. @param {Person} person @returns {void}

deno doc MyModule.ts Namespace.Klass

➜ deno doc MyModule.ts Namespace.Klass

Defined in file:///Users/mark/Deno/MyModule.ts:37:2 

class Klass
    안쪽의 문서도 밖에서 보입니다.

SUBCOMMAND : install

➜ deno help install
deno-install 
Installs a script as an executable in the installation root's bin directory.
  deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
  deno install https://deno.land/std/examples/colors.ts

To change the executable name, use -n/--name:
  deno install --allow-net --allow-read -n serve https://deno.land/std/http/file_server.ts

The executable name is inferred by default:
  - Attempt to take the file stem of the URL path. The above example would
    become 'file_server'.
  - If the file stem is something generic like 'main', 'mod', 'index' or 'cli',
    and the path has no parent, take the file name of the parent path. Otherwise
    settle with the generic name.

To change the installation root, use --root:
  deno install --allow-net --allow-read --root /usr/local https://deno.land/std/http/file_server.ts

The installation root is determined, in order of precedence:
  - --root option
  - DENO_INSTALL_ROOT environment variable
  - $HOME/.deno

These must be added to the path manually if required.

USAGE:
    deno install [OPTIONS] <cmd>...

OPTIONS:
    -A, --allow-all                    Allow all permissions
        --allow-env                    Allow environment access
        --allow-hrtime                 Allow high resolution time measurement
        --allow-net=<allow-net>        Allow network access
        --allow-plugin                 Allow loading plugins
        --allow-read=<allow-read>      Allow file system read access
        --allow-run                    Allow running subprocesses
        --allow-write=<allow-write>    Allow file system write access
        --cert <FILE>                  Load certificate authority from PEM encoded file
    -f, --force                        Forcefully overwrite existing installation
    -h, --help                         Prints help information
    -L, --log-level <log-level>        Set log level [possible values: debug, info]
    -n, --name <name>                  Executable file name
    -q, --quiet                        Suppress diagnostic output
        --root <root>                  Installation root
        --unstable                     Enable unstable APIs

ARGS:
    <cmd>...    

install 하고 사용하기

~/Deno via ⬢ v12.16.3 
➜ deno install --allow-read --allow-net https://deno.land/std/http/file_server.ts
Download https://deno.land/std/http/file_server.ts
Warning Implicitly using master branch https://deno.land/std/http/file_server.ts
Download https://deno.land/std/path/mod.ts
Download https://deno.land/std/http/server.ts
Download https://deno.land/std/flags/mod.ts
Download https://deno.land/std/_util/assert.ts
Warning Implicitly using master branch https://deno.land/std/flags/mod.ts
Warning Implicitly using master branch https://deno.land/std/http/server.ts
Warning Implicitly using master branch https://deno.land/std/_util/assert.ts
Download https://deno.land/std/encoding/utf8.ts
Download https://deno.land/std/io/bufio.ts
Download https://deno.land/std/async/mod.ts
Download https://deno.land/std/http/_io.ts
Warning Implicitly using master branch https://deno.land/std/path/mod.ts
Download https://deno.land/std/path/_constants.ts
Download https://deno.land/std/path/win32.ts
Download https://deno.land/std/path/posix.ts
Download https://deno.land/std/path/common.ts
Download https://deno.land/std/path/separator.ts
Download https://deno.land/std/path/_interface.ts
Download https://deno.land/std/path/glob.ts
Warning Implicitly using master branch https://deno.land/std/io/bufio.ts
Download https://deno.land/std/io/util.ts
Warning Implicitly using master branch https://deno.land/std/http/_io.ts
Warning Implicitly using master branch https://deno.land/std/async/mod.ts
Download https://deno.land/std/textproto/mod.ts
Download https://deno.land/std/http/http_status.ts
Download https://deno.land/std/async/deferred.ts
Download https://deno.land/std/async/delay.ts
Download https://deno.land/std/async/mux_async_iterator.ts
Warning Implicitly using master branch https://deno.land/std/encoding/utf8.ts
Warning Implicitly using master branch https://deno.land/std/path/win32.ts
Warning Implicitly using master branch https://deno.land/std/path/common.ts
Download https://deno.land/std/path/_util.ts
Warning Implicitly using master branch https://deno.land/std/path/_constants.ts
Warning Implicitly using master branch https://deno.land/std/path/separator.ts
Warning Implicitly using master branch https://deno.land/std/path/posix.ts
Warning Implicitly using master branch https://deno.land/std/path/glob.ts
Download https://deno.land/std/path/_globrex.ts
Warning Implicitly using master branch https://deno.land/std/path/_interface.ts
Warning Implicitly using master branch https://deno.land/std/io/util.ts
Warning Implicitly using master branch https://deno.land/std/textproto/mod.ts
Warning Implicitly using master branch https://deno.land/std/async/mux_async_iterator.ts
Download https://deno.land/std/bytes/mod.ts
Warning Implicitly using master branch https://deno.land/std/async/delay.ts
Warning Implicitly using master branch https://deno.land/std/async/deferred.ts
Warning Implicitly using master branch https://deno.land/std/http/http_status.ts
Warning Implicitly using master branch https://deno.land/std/path/_util.ts
Warning Implicitly using master branch https://deno.land/std/path/_globrex.ts
Warning Implicitly using master branch https://deno.land/std/bytes/mod.ts
Compile https://deno.land/std/http/file_server.ts
✅ Successfully installed file_server
/Users/mark/.deno/bin/file_server

~/Deno via ⬢ v12.16.3 took 3s 
➜ file_server
HTTP server listening on http://0.0.0.0:4507/

사용하려면 main 이 있어야 함

~/Deno via ⬢ v12.16.3 
➜ deno install https://deno.land/std/examples/colors.ts
Download https://deno.land/std/examples/colors.ts
Warning Implicitly using master branch https://deno.land/std/examples/colors.ts
Download https://deno.land/std/fmt/colors.ts
Warning Implicitly using master branch https://deno.land/std/fmt/colors.ts
Compile https://deno.land/std/examples/colors.ts
✅ Successfully installed colors
/Users/mark/.deno/bin/colors

~/Deno via ⬢ v12.16.3 took 2s 
➜ colors

사용하려면 main 이 있어야 함

if (import.meta.main) {
  main();
}

어디에 인스톨될지 우선순위

--root option

DENO_INSTALL_ROOT environment variable

$HOME/.deno

이름을 내마음대로 바꾸는 옵션 -n

~/Deno
➜ deno install --allow-read --allow-net -n fs https://deno.land/std/http/file_server.ts
Download https://deno.land/std/http/file_server.ts
Warning Implicitly using master branch https://deno.land/std/http/file_server.ts
Download https://deno.land/std/path/mod.ts
Download https://deno.land/std/http/server.ts
Download https://deno.land/std/flags/mod.ts
Download https://deno.land/std/_util/assert.ts
Warning Implicitly using master branch https://deno.land/std/path/mod.ts
Download https://deno.land/std/path/_constants.ts
Download https://deno.land/std/path/win32.ts
Download https://deno.land/std/path/posix.ts
Download https://deno.land/std/path/common.ts
Download https://deno.land/std/path/separator.ts
Download https://deno.land/std/path/_interface.ts
Download https://deno.land/std/path/glob.ts
Warning Implicitly using master branch https://deno.land/std/_util/assert.ts
Warning Implicitly using master branch https://deno.land/std/flags/mod.ts
Warning Implicitly using master branch https://deno.land/std/http/server.ts
Download https://deno.land/std/encoding/utf8.ts
Download https://deno.land/std/io/bufio.ts
Download https://deno.land/std/async/mod.ts
Download https://deno.land/std/http/_io.ts
Warning Implicitly using master branch https://deno.land/std/path/posix.ts
Warning Implicitly using master branch https://deno.land/std/path/separator.ts
Warning Implicitly using master branch https://deno.land/std/path/_constants.ts
Warning Implicitly using master branch https://deno.land/std/path/win32.ts
Download https://deno.land/std/path/_util.ts
Warning Implicitly using master branch https://deno.land/std/path/common.ts
Warning Implicitly using master branch https://deno.land/std/path/_interface.ts
Warning Implicitly using master branch https://deno.land/std/path/glob.ts
Download https://deno.land/std/path/_globrex.ts
Warning Implicitly using master branch https://deno.land/std/io/bufio.ts
Download https://deno.land/std/io/util.ts
Warning Implicitly using master branch https://deno.land/std/encoding/utf8.ts
Warning Implicitly using master branch https://deno.land/std/http/_io.ts
Download https://deno.land/std/textproto/mod.ts
Download https://deno.land/std/http/http_status.ts
Warning Implicitly using master branch https://deno.land/std/async/mod.ts
Download https://deno.land/std/async/deferred.ts
Download https://deno.land/std/async/delay.ts
Download https://deno.land/std/async/mux_async_iterator.ts
Warning Implicitly using master branch https://deno.land/std/path/_util.ts
Warning Implicitly using master branch https://deno.land/std/path/_globrex.ts
Warning Implicitly using master branch https://deno.land/std/io/util.ts
Warning Implicitly using master branch https://deno.land/std/textproto/mod.ts
Download https://deno.land/std/bytes/mod.ts
Warning Implicitly using master branch https://deno.land/std/async/delay.ts
Warning Implicitly using master branch https://deno.land/std/async/deferred.ts
Warning Implicitly using master branch https://deno.land/std/async/mux_async_iterator.ts
Warning Implicitly using master branch https://deno.land/std/http/http_status.ts
Warning Implicitly using master branch https://deno.land/std/bytes/mod.ts
Compile https://deno.land/std/http/file_server.ts
✅ Successfully installed fs
/Users/mark/.deno/bin/fs

~/Deno took 4s 
➜ fs
HTTP server listening on http://0.0.0.0:4507/

Module Integrity checking

lock.json

사용하는 모듈의 무결성을 위한 lock.json 파일 생성

~/Deno 
➜ deno cache --lock=lock.json --lock-write welcome-with-color.ts 

{
  "https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts": "06444b6ebc3842a4b2340d804bfa81fc5452a03513cbb81bd7f6bf8f4b8f3ac4"
}

다른 머신에서 lock.json 을 기반으로 모듈 캐싱하기

~/Deno
➜ deno cache --reload --lock=lock.json welcome-with-color.ts
Download https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts
Compile file:///Users/mark/Deno/welcome-with-color.ts

문제가 있는 경우 failed

~/Deno via ⬢ v12.16.3 
➜ deno cache --reload --lock=lock.json welcome-with-color.ts
Download https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts
Compile file:///Users/mark/Deno/welcome-with-color.ts
Subresource integrity check failed --lock=lock.json
https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts

run 하면서 사용하는 모듈의 무결성 체크

~/Deno
➜ deno run --lock=lock.json welcome-with-color.ts
Hello Deno

~/Deno
➜ deno run --lock=lock.json welcome-with-color.ts
Subresource integrity check failed --lock=lock.json
https://raw.githubusercontent.com/denoland/deno/master/std/fmt/colors.ts

캐시되어 무결성 체크안에 포함되어 있지 않으면 실행되지 않는다.

--cached-only

~/Deno via ⬢ v12.16.3 
➜ deno run --lock=lock.json --cached-only welcome-with-color.ts
error: Cannot find module "https://raw.githubusercontent.com/denoland/deno/master/std/log/mod.ts" from "file:///Users/mark/Deno/welcome-with-color.ts" in cache, --cached-only is specified

dependency inspector

deno info

➜ deno info server.ts 
[1/1] Compiling file:///Users/mark/deno/deno-is-coming/server.ts
local: /Users/mark/deno/deno-is-coming/server.ts
type: TypeScript
compiled: /Users/mark/Library/Caches/deno/gen/8a1c598995d9637a1462100c9e341520af130247.js
map: /Users/mark/Library/Caches/deno/gen/8a1c598995d9637a1462100c9e341520af130247.js.map
deps:
file:///Users/mark/deno/deno-is-coming/server.ts
  └─┬ https://deno.land/std@v0.5/http/server.ts
    ├─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/io/bufio.ts
    │ ├─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/io/util.ts
    │ │ ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/strings/strings.ts
    │ │ └─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path.ts
    │ │   └─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/mod.ts
    │ │     ├─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/win32.ts
    │ │     │ ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/constants.ts
    │ │     │ └─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/utils.ts
    │ │     │   └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/constants.ts
    │ │     ├─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/posix.ts
    │ │     │ ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/constants.ts
    │ │     │ └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/utils.ts
    │ │     └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/fs/path/constants.ts
    │ └─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/asserts.ts
    │   └─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/pretty.ts
    │     ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/asserts.ts
    │     ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/colors/mod.ts
    │     ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/diff.ts
    │     └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/format.ts
    ├─┬ https://raw.githubusercontent.com/denoland/deno_std/v0.5/textproto/mod.ts
    │ └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/io/util.ts
    ├── https://raw.githubusercontent.com/denoland/deno_std/v0.5/http/http_status.ts
    └── https://raw.githubusercontent.com/denoland/deno_std/v0.5/testing/asserts.ts

SUBCOMMANDS : info (의존 모듈 트리 보기)

➜ deno help info                                            
deno-info 
Information about a module or the cache directories.

Get information about a module:
  deno info https://deno.land/std/http/file_server.ts

The following information is shown:

local: Local path of the file.
type: JavaScript, TypeScript, or JSON.
compiled: Local path of compiled source code. (TypeScript only.)
map: Local path of source map. (TypeScript only.)
deps: Dependency tree of the source file.

Without any additional arguments, 'deno info' shows:

DENO_DIR: Directory containing Deno-managed files.
Remote modules cache: Subdirectory containing downloaded remote modules.
TypeScript compiler cache: Subdirectory containing TS compiler output.

USAGE:
    deno info [OPTIONS] [file]

OPTIONS:
        --cert <FILE>              Load certificate authority from PEM encoded file
    -h, --help                     Prints help information
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output
        --unstable                 Enable unstable APIs

ARGS:
    <file>    

SUBCOMMANDS : info (의존 모듈 트리 보기)

➜ deno info https://deno.land/std@0.52.0/http/file_server.ts
Download https://deno.land/std@0.52.0/http/file_server.ts
Download https://deno.land/std@0.52.0/path/mod.ts
Download https://deno.land/std@0.52.0/http/server.ts
Download https://deno.land/std@0.52.0/flags/mod.ts
Download https://deno.land/std@0.52.0/testing/asserts.ts
Download https://deno.land/std@0.52.0/fmt/colors.ts
Download https://deno.land/std@0.52.0/testing/diff.ts
Download https://deno.land/std@0.52.0/path/win32.ts
Download https://deno.land/std@0.52.0/path/posix.ts
Download https://deno.land/std@0.52.0/path/common.ts
Download https://deno.land/std@0.52.0/path/separator.ts
Download https://deno.land/std@0.52.0/path/interface.ts
Download https://deno.land/std@0.52.0/path/glob.ts
Download https://deno.land/std@0.52.0/encoding/utf8.ts
Download https://deno.land/std@0.52.0/io/bufio.ts
Download https://deno.land/std@0.52.0/async/mod.ts
Download https://deno.land/std@0.52.0/http/_io.ts
Download https://deno.land/std@0.52.0/path/_constants.ts
Download https://deno.land/std@0.52.0/path/_util.ts
Download https://deno.land/std@0.52.0/path/_globrex.ts
Download https://deno.land/std@0.52.0/textproto/mod.ts
Download https://deno.land/std@0.52.0/http/http_status.ts
Download https://deno.land/std@0.52.0/async/deferred.ts
Download https://deno.land/std@0.52.0/async/delay.ts
Download https://deno.land/std@0.52.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.52.0/io/util.ts
Download https://deno.land/std@0.52.0/bytes/mod.ts
Compile https://deno.land/std@0.52.0/http/file_server.ts
local: /Users/mark/Library/Caches/deno/deps/https/deno.land/5bd138988e9d20db1a436666628ffb3f7586934e0a2a9fe2a7b7bf4fb7f70b98
type: TypeScript
compiled: /Users/mark/Library/Caches/deno/gen/https/deno.land/std@0.52.0/http/file_server.ts.js
map: /Users/mark/Library/Caches/deno/gen/https/deno.land/std@0.52.0/http/file_server.ts.js.map
deps:
https://deno.land/std@0.52.0/http/file_server.ts
  ├─┬ https://deno.land/std@0.52.0/path/mod.ts
  │ ├─┬ https://deno.land/std@0.52.0/path/win32.ts
  │ │ ├── https://deno.land/std@0.52.0/path/_constants.ts
  │ │ ├─┬ https://deno.land/std@0.52.0/path/_util.ts
  │ │ │ └── https://deno.land/std@0.52.0/path/_constants.ts
  │ │ └─┬ https://deno.land/std@0.52.0/testing/asserts.ts
  │ │   ├── https://deno.land/std@0.52.0/fmt/colors.ts
  │ │   └── https://deno.land/std@0.52.0/testing/diff.ts
  │ ├─┬ https://deno.land/std@0.52.0/path/posix.ts
  │ │ ├── https://deno.land/std@0.52.0/path/_constants.ts
  │ │ └── https://deno.land/std@0.52.0/path/_util.ts
  │ ├─┬ https://deno.land/std@0.52.0/path/common.ts
  │ │ └── https://deno.land/std@0.52.0/path/separator.ts
  │ ├── https://deno.land/std@0.52.0/path/separator.ts
  │ ├── https://deno.land/std@0.52.0/path/interface.ts
  │ └─┬ https://deno.land/std@0.52.0/path/glob.ts
  │   ├── https://deno.land/std@0.52.0/path/separator.ts
  │   ├── https://deno.land/std@0.52.0/path/_globrex.ts
  │   ├── https://deno.land/std@0.52.0/path/mod.ts
  │   └── https://deno.land/std@0.52.0/testing/asserts.ts
  ├─┬ https://deno.land/std@0.52.0/http/server.ts
  │ ├── https://deno.land/std@0.52.0/encoding/utf8.ts
  │ ├─┬ https://deno.land/std@0.52.0/io/bufio.ts
  │ │ ├─┬ https://deno.land/std@0.52.0/io/util.ts
  │ │ │ ├── https://deno.land/std@0.52.0/path/mod.ts
  │ │ │ └── https://deno.land/std@0.52.0/encoding/utf8.ts
  │ │ └── https://deno.land/std@0.52.0/testing/asserts.ts
  │ ├── https://deno.land/std@0.52.0/testing/asserts.ts
  │ ├─┬ https://deno.land/std@0.52.0/async/mod.ts
  │ │ ├── https://deno.land/std@0.52.0/async/deferred.ts
  │ │ ├── https://deno.land/std@0.52.0/async/delay.ts
  │ │ └─┬ https://deno.land/std@0.52.0/async/mux_async_iterator.ts
  │ │   └── https://deno.land/std@0.52.0/async/deferred.ts
  │ └─┬ https://deno.land/std@0.52.0/http/_io.ts
  │   ├── https://deno.land/std@0.52.0/io/bufio.ts
  │   ├─┬ https://deno.land/std@0.52.0/textproto/mod.ts
  │   │ ├── https://deno.land/std@0.52.0/io/util.ts
  │   │ ├─┬ https://deno.land/std@0.52.0/bytes/mod.ts
  │   │ │ └── https://deno.land/std@0.52.0/io/util.ts
  │   │ └── https://deno.land/std@0.52.0/encoding/utf8.ts
  │   ├── https://deno.land/std@0.52.0/testing/asserts.ts
  │   ├── https://deno.land/std@0.52.0/encoding/utf8.ts
  │   ├── https://deno.land/std@0.52.0/http/server.ts
  │   └── https://deno.land/std@0.52.0/http/http_status.ts
  ├─┬ https://deno.land/std@0.52.0/flags/mod.ts
  │ └── https://deno.land/std@0.52.0/testing/asserts.ts
  └── https://deno.land/std@0.52.0/testing/asserts.ts

code formatter

deno fmt

➜ deno fmt -r [파일명]   
[42/44] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/standalon[43/44] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/standalon[43/45] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ty[44/45] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ty[44/46] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ba[45/46] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ba[45/47] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ma[46/47] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ma[46/48] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/standalon[47/48] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/standalon[47/49] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ty[48/49] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ty[48/50] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ba[49/50] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ba[49/51] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ma[50/51] Downloading https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/vendor/parser_ma[51/51] Compiling https://raw.githubusercontent.com/denoland/deno_std/v0.7.0/prettier/main.ts
Formatting [파일명]

음 prettier rule 은?

deno 에서 prettier 지원하는 것

일관적인 설정을 가진 code formatting 기능을 지원하는 것 

Deno 1.0

  •  "deno fmt" is slow on the first run. It download a couple of large prettier bundles. #2490

SUBCOMMANDS : fmt (포매터)

➜ deno help fmt  
deno-fmt 
Auto-format JavaScript/TypeScript source code.
  deno fmt
  deno fmt myfile1.ts myfile2.ts
  deno fmt --check

Format stdin and write to stdout:
  cat file.ts | deno fmt -

Ignore formatting code by preceding it with an ignore comment:
  // deno-fmt-ignore

Ignore formatting a file by adding an ignore comment at the top of the file:
  // deno-fmt-ignore-file

USAGE:
    deno fmt [OPTIONS] [files]...

OPTIONS:
        --check                    Check if the source files are formatted.
    -h, --help                     Prints help information
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output

ARGS:
    <files>...    

특정 파일 포매팅 되어 있는지 체크하고, 포매팅 하기

~/Deno via ⬢ v12.16.3 
➜ deno fmt --check MyModule.ts

from MyModule.ts:
02| -    name: string;
02| +  name: string;

error: Found 1 not formatted file

~/Deno via ⬢ v12.16.3 
➜ deno fmt MyModule.ts        
MyModule.ts

~/Deno via ⬢ v12.16.3 
➜ deno fmt --check MyModule.ts

현재 위치 기준 하위 디렉토리 포매팅 체크하고, 포매팅 하기

~/Deno via ⬢ v12.16.3 
➜ deno fmt --check

from /Users/mark/Deno/MyModule.ts:
02| -    name: string;
02| +  name: string;

error: Found 1 not formatted file

~/Deno via ⬢ v12.16.3 
➜ deno fmt        
/Users/mark/Deno/MyModule.ts

~/Deno via ⬢ v12.16.3 
➜ deno fmt --check

포매팅 안하고 싶으면 주석 처리 : // deno-fmt-ignore-file

// deno-fmt-ignore-file

SUBCOMMANDS : lint

~/Deno via ⬢ v12.16.3 
➜ deno lint MyModule.ts
Unstable API 'lint'. The --unstable flag must be provided.

~/Deno via ⬢ v12.16.3 
➜ deno lint --unstable MyModule.ts 
(no-namespace) custom typescript modules are outdated
export namespace Namespace {
       ~~~~~~~~~~~~~~~~~~~~~
    at MyModule.ts:33:7

Found 1 problems

SUBCOMMANDS : type

➜ deno help types
deno-types 
Print runtime TypeScript declarations.
  deno types > lib.deno.d.ts

The declaration file could be saved and used for typing information.

USAGE:
    deno types [OPTIONS]

OPTIONS:
    -h, --help                     Prints help information
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output
        --unstable                 Enable unstable APIs
// d.ts 출력
➜ deno types            

➜ deno types > lib.deno.d.ts

Security & Permission

No network and filesystem access by default

➜ deno run https://deno.land/std/http/file_server.ts
error: Uncaught PermissionDenied: read access to <CWD>, run again with the --allow-read flag
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.cwd ($deno$/ops/fs/dir.ts:5:10)
    at Module.resolve (https://deno.land/std/path/posix.ts:31:19)
    at https://deno.land/std/http/file_server.ts:36:22

파일을 읽을 수 없어서 프로그램이 죽는다.

➜ deno run --allow-read https://deno.land/std/http/file_server.ts
HTTP server listening on http://0.0.0.0:4507/
error: Uncaught PermissionDenied: network access to "0.0.0.0:4507", run again with the --allow-net flag
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listen ($deno$/ops/net.ts:51:10)
    at Object.listen ($deno$/net.ts:154:22)
    at serve (https://deno.land/std/http/server.ts:256:25)
    at listenAndServe (https://deno.land/std/http/server.ts:276:18)
    at main (https://deno.land/std/http/file_server.ts:326:3)
    at https://deno.land/std/http/file_server.ts:365:3

네트워크를 열 수 없어서 프로그램이 죽는다.

➜ deno run --allow-read --allow-net https://deno.land/std/http/file_server.ts
HTTP server listening on http://0.0.0.0:4507/
[2020-06-15 00:58:18] "GET / HTTP/1.1" 200
No such file or directory (os error 2)
[2020-06-15 00:58:18] "GET /favicon.ico HTTP/1.1" 404

필요한 모든 권한이 있으므로 프로그램이 죽지않고 실행된다.

  • -A, --allow-all Allow all permissions. This disables all security.

  • --allow-env Allow environment access for things like getting and setting of environment variables.

  • --allow-hrtime Allow high resolution time measurement. High resolution time can be used in timing attacks and fingerprinting.

  • --allow-net=\<allow-net> Allow network access. You can specify an optional, comma separated list of domains to provide a allow-list of allowed domains.

  • --allow-plugin Allow loading plugins. Please note that --allow-plugin is an unstable feature.

  • --allow-read=\<allow-read> Allow file system read access. You can specify an optional, comma separated list of directories or files to provide a allow-list of allowed file system access.

  • --allow-run Allow running subprocesses. Be aware that subprocesses are not run in a sandbox and therefore do not have the same security restrictions as the deno process. Therefore, use with caution.

  • --allow-write=\<allow-write> Allow file system write access. You can specify an optional, comma separated list of directories or files to provide a allow-list of allowed file system access.

~/Deno via ⬢ v12.16.3 
➜ deno run --allow-read=/Users/mark/Deno --allow-net https://deno.land/std/http/file_server.ts
HTTP server listening on http://0.0.0.0:4507/
^C

~/Deno via ⬢ v12.16.3 
➜ deno run --allow-read=/Users/mark/Deno,/Users/mark/Desktop --allow-net https://deno.land/std/http/file_server.ts
HTTP server listening on http://0.0.0.0:4507/

특정 경로만 퍼미션을 줄 수 있다. (allow-write 도 마찬가지)

const result = await fetch("https://deno.land/");
console.log(result);

~/Deno via ⬢ v12.16.3 
➜ deno run --allow-net=deno.land fetch.ts
Response {
  _bodySource: ReadableStream { locked: false },
  contentType: "text/html",
  _stream: null,
  url: "https://deno.land/",
  statusText: "OK",
  status: 200,
  headers: Headers { date: Mon, 15 Jun 2020 05:22:54 GMT, content-type: text/html, set-cookie: __cfduid=de8cd74e317340ff73dbb966ba766283d1592198573; expires=Wed, 15-Jul-20 05:22:53 GMT; path=/; domain=.deno.land; HttpOnly; SameSite=Lax; Secure, cf-ray: 5a39db1badb8996b-LAX, access-control-allow-origin: *, age: 51876, cache-control: public, max-age=0, must-revalidate, content-disposition: inline, strict-transport-security: max-age=63072000; includeSubDomains; preload, cf-cache-status: DYNAMIC, cf-request-id: 03580745450000996bd6222200000001, expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct", x-vercel-cache: HIT, x-vercel-id: sfo1::9vndm-1592198574031-86fcd4834b90, x-vercel-trace: sfo1, vary: Accept-Encoding, server: cloudflare },
  redirected: false,
  type: "default"
}

특정 도메인 영역만 네트워크를 허가할 수 있다.

Deno Workshop 1st

By Woongjae Lee

Deno Workshop 1st

Deno Online Workshop

  • 1,207