Deno's standard library offers trusted, well-maintained utilities that integrate smoothly with its runtime. It is not meant to replace all third-party modules or limit developers but to provide a solid foundation.
import { existsSync } from "https://deno.land/std/fs/mod.ts"; const result = existsSync("./nonexistent-file.txt"); console.log(result);
The function `existsSync` checks synchronously if a file or directory exists at the given path. It returns false if the path does not exist, without throwing an error.
Option A correctly pins the version and uses named import syntax. Option A lacks version pinning which is discouraged. Option A uses default import which is invalid here. Option A uses 'latest' which is not a valid version tag.
import { readJson } from "https://deno.land/std/fs/mod.ts"; async function main() { const data = await readJson("./data.json"); console.log(data); } main();
The code uses 'await' inside a non-async function, causing a SyntaxError: Unexpected await outside async function.
import { join } from "https://deno.land/std/path/mod.ts"; const result = join("/home/user", "../docs", "./file.txt"); console.log(result);
The join function normalizes the path by resolving .. and . segments. So, joining /home/user, ../docs, and ./file.txt results in /home/docs/file.txt.
