new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Deno · Reference · all subjects

cli commands/eval

11 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

deno eval example: CommonJS detection

Examples of CommonJS vs ESM detection: # Detected as CommonJS — uses require() deno eval "const path = require('path'); console.log(path.join('a', 'b'))" # Runs as ESM (the default) — no CJS-specific patterns deno eval "console.log(1 + 2)" # Runs as ESM because of the static import deno eval "import { ok } from 'node:assert'; ok(true); console.log('ok')" The first snippet is detected as CommonJS, the second and third run as ESM.

deno eval command basic usage

deno eval executes a string of code directly from the command line without needing a file.

deno eval runs with all permissions enabled by default

Unlike deno run, deno eval runs with all permissions enabled by default.

deno eval supports TypeScript

TypeScript works out of the box with deno eval without any additional configuration.

deno eval CommonJS vs ESM auto-detection

Starting in Deno 2.8, deno eval defaults to ESM but switches to CommonJS when the snippet has no import/export declarations and references CommonJS-specific bindings: require(, module.exports, exports., __dirname, or __filename.

deno eval --ext flag to override module detection

Pass --ext=mjs to force ESM or --ext=cjs to force CommonJS when the auto-detection heuristic gets it wrong, such as when a snippet mentions require only inside a string.

deno eval --print flag for expression results

Use --print (or -p) to evaluate an expression and print its result, similar to node -p.

deno eval can read from stdin

deno eval can be combined with piped input for quick data processing by reading from Deno.stdin.readable.

deno eval example: print expression result

Example showing deno eval -p flag usage: deno eval -p "1 + 2" # 3 deno eval -p "Deno.version" # { deno: "2.x.x", v8: "...", typescript: "..." } The -p flag evaluates an expression and prints the result.

deno eval example: read from stdin

Example showing piped input to deno eval: echo '{"name":"deno"}' | deno eval -p " const text = await new Response(Deno.stdin.readable).text(); JSON.parse(text).name " This demonstrates reading JSON from stdin and parsing it.

deno eval command

deno eval is used to evaluate provided script.

Give your agent this brain