deno test # Run all testsdeno test math_test.ts # Run specific test
Configuration
deno.json
{"compilerOptions":{"allowJs":true,"lib":["deno.window"],"strict":true},"lint":{"rules":{"tags":["recommended"],"exclude":["no-unused-vars"]}},"fmt":{"useTabs":false,"lineWidth":80,"indentWidth":2,"semiColons":true,"singleQuote":false},"tasks":{"dev":"deno run --watch main.ts","test":"deno test --allow-all"}}
Development Tools
Built-in tools:
deno fmt # Format codedeno lint # Lint code deno test # Run testsdeno doc # Generate documentationdeno compile # Compile to executabledeno bundle # Bundle modules
LSP Integration
Most editors support Deno through the Language Server Protocol: - VS Code: Deno extension - Vim/Neovim: Built-in LSP support - Other editors: Configure LSP client
Web APIs
Deno implements many web standard APIs:
// Fetch APIconst response =awaitfetch("https://api.github.com/users/denoland");const data =await response.json();console.log(`Deno has ${data.public_repos} public repositories`);// Web Streamsconst readable =newReadableStream({start(controller) { controller.enqueue("Hello "); controller.enqueue("World!"); controller.close(); }});const reader = readable.getReader();let result ="";while (true) {const { done, value } =await reader.read();if (done) break; result += value;}console.log(result);// WebAssembly - Simple example that adds two numbersconst wasmBytes =newUint8Array([0x00,0x61,0x73,0x6d,0x01,0x00,0x00,0x00,0x01,0x07,0x01,0x60,0x02,0x7f,0x7f,0x01,0x7f,0x03,0x02,0x01,0x00,0x07,0x07,0x01,0x03,0x61,0x64,0x64,0x00,0x00,0x0a,0x09,0x01,0x07,0x00,0x20,0x00,0x20,0x01,0x6a,0x0b]);const wasmModule =await WebAssembly.instantiate(wasmBytes);const addFunction = wasmModule.instance.exports.add;console.log(`WASM add(5, 3) = ${addFunction(5,3)}`);
Deno has 205 public repositories
Hello World!
WASM add(5, 3) = 8