Deno logo

Deno Cheat Sheet

For Deno v1.0.0

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
repl Read Eval Print Loop
run Run a program given a filename or url to the module
test Run tests
types Print runtime TypeScript declarations
upgrade Upgrade deno executable to given version
Run options
Permissions
-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
Other
--cached-only Require that remote dependencies are already cached
--cert <FILE> Load certificate authority from PEM encoded file
-h--help
--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 (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
--version Prints the Deno version
Environment variables
DENO_DIR Set deno's base directory (defaults to $HOME/.deno)
DENO_INSTALL_ROOT Set deno install's output directory
(defaults to $HOME/.deno/bin)
NO_COLOR Set to disable color
HTTP_PROXY Proxy address for HTTP requests
(module downloads, fetch)
HTTPS_PROXY Same but for HTTPS
Functions
Deno.chdir Change the current working directory to the specified path
Deno.chmod Changes the permission of a specific file / directory of specified path.
Deno.chmodSync
Deno.chown
Deno.chownSync
Deno.close
Deno.connect
Deno.connectTls
Deno.copy
Deno.copyFile
Deno.copyFileSync
Deno.create
Deno.createSync
Deno.cwd
Deno.execPath
Deno.exit
Deno.inspect
Deno.isatty
Deno.iter
Deno.iterSync
Deno.listen
Deno.listenTls
Deno.lstat
Deno.lstatSync
Deno.makeTempDir
Deno.makeTempDirSync
Deno.makeTempFile
Deno.makeTempFileSync
Deno.metrics
Deno.mkdir
Deno.mkdirSync
Deno.open
Deno.openSync
Deno.read
Deno.readAll
Deno.readAllSync
Deno.readDir
Deno.readDirSync
Deno.readFile
Deno.readFileSync
Deno.readLink
Deno.readLinkSync
Deno.readSync
Deno.readTextFile
Deno.readTextFileSync
Deno.realPath
Deno.realPathSync
Deno.remove
Deno.removeSync
Deno.rename
Deno.renameSync
Deno.resources
Deno.run
Deno.seek
Deno.seekSync
Deno.stat
Deno.statSync
Deno.test
Deno.test
Deno.truncate
Deno.truncateSync
Deno.watchFs
Deno.write
Deno.writeAll
Deno.writeAllSync
Deno.writeFile
Deno.writeFileSync
Deno.writeSync
Deno.writeTextFile
Deno.writeTextFileSync
addEventListener
atob
btoa
clearInterval
clearTimeout
dispatchEvent
fetch
performance.now
queueMicrotask
removeEventListener
setInterval
setTimeout

Standard Library
_util
archive
async
bytes
datetime
encoding
examples
flags
fmt
fs
hash
http
io
log
mime
node
path
permissions
signal
testing
textproto
uuid
ws
manual
version
SL datetime
parseDate() Take an input string and a format to parse the date.
parseDateTime() Take an input string and a format to parse the dateTime.
dayOfYear() Returns the number of the day in the year.
currentDayOfYear() Returns the number of the current day in the year.
SL encoding
Data types
base32
binary
csv
toml
yaml
SL http
{serve} from "…/server.ts"
{ServerRequest} from "…/server.ts"
{Response} from "…/server.ts"
{Headers} from ""
{Cookie} from "…/cookie.ts"
{getCookies} from "…/cookie.ts"
{setCookie} from "…/cookie.ts"
{delCookie} from "…/cookie.ts"
SL fs
emptyDir() Ensures that a directory is empty
emptyDirSync()
ensureDir() Ensures that the directory exists
ensureDirSync()
ensureFile() Ensures that the file exists
ensureFileSync()
ensureSymlink() Ensures that the link exists
ensureSymlinkSync()
format()
detect()
EOL Detects and format the passed string for the targeted End Of Line character
exists() Test whether or not the given path exists by checking with the file system
existsSync()
move() Moves a file or directory
moveSync()
copy() Copy a file or directory
copySync()
readJson() Reads a JSON file and then parses it into an object
readJsonSync()
writeJson() Writes an object to a JSON file
writeJsonSync()
walk() Iterate all files in a directory recursively
walkSync()
readFileStr() Read file and output it as a string
readFileStrSync()
writeFileStr() Write the string to file
writeFileStrSync()
SL log
log.debug()
log.info()
log.warning()
log.error()
log.critical()
log.setup()
log.handlers.ConsoleHandler()
log.handlers.FileHandler()
log.getLogger()
SL testing
equal() Deep comparison; actual and expected are compared deeply
assert() Expects a boolean value; throws if the value is false
assertEquals() Uses equal comparison; throws if actual !== expected
assertNotEquals() Uses equal comparison; throws if actual === expected
assertStrictEq() Compares actual and expected strictly
assertStrContains() Make assertion: actual contains expected
assertMatch() Make assertion: actual match RegExp expected
assertArrayContains() Make assertion: actual array contains the expected values
assertThrows() Expects passed fn to throw. If fn does not, this function does
assertThrowsAsync() Expects passed fn to be async and throw (or return a Promise that rejects)
unimplemented() Use this to stub out methods that will throw when invoked
unreachable() Used to assert unreachable code
Benchmarking
bench() Registers a benchmark that will be run once runBenchmarks is called
runBenchmarks() Runs all registered benchmarks serially
runIfMain() Runs specified benchmarks if the enclosing script is main
i BenchmarkTimer Provides methods for starting and stopping a benchmark clock
i BenchmarkFunction Defines a benchmark through a named function
i BenchmarkDefinition Defines a benchmark definition with configurable runs
i BenchmarkRunOptions Defines runBenchmark's run constraints by matching benchmark names
SL bytes
findIndex() Find first index of binary pattern from given binary array
findLastIndex() Find last index of binary pattern from given binary array
equal() Check whether given binary arrays are equal to each other
hasPrefix() Check whether binary array has binary prefix
hasSuffix() Check whether binary array has binary suffix
repeat() Repeat bytes of given binary array and return new one
concat() Concatenate two binary arrays and return new one
SL uuid
v4.generate()
v4.validate()
SL ws
isWebSocketCloseEvent() Returns true if input value is a WebSocketCloseEvent, false otherwise
isWebSocketPingEvent() Returns true if input value is a WebSocketPingEvent, false otherwise
isWebSocketPongEvent() Returns true if input value is a WebSocketPongEvent, false otherwise
unmask() Unmask masked WebSocket payload
writeFrame() Write WebSocket frame to inputted writer
readFrame() Read WebSocket frame from inputted BufReader
createMask() Create mask from the client to the server with random 32bit number
acceptable Returns true if input headers are usable for WebSocket, otherwise false
createSecAccept() Create value of Sec-WebSocket-Accept header from inputted nonce
acceptWebSocket() Upgrade inputted TCP connection into WebSocket connection
createSecKey() Returns base64 encoded 16 bytes string for Sec-WebSocket-Key header
connectWebSocket() Connect to WebSocket endpoint url with inputted endpoint string and headers