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

node apis

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

Node.js globals supported by Deno

Deno supports the following Node.js globals, which are available in the npm package scope. In own code, they can be imported from relevant node: modules. Supported globals: AbortController, AbortSignal, Blob, Buffer, ByteLengthQueuingStrategy, atob, BroadcastChannel, btoa, clearImmediate, clearInterval, clearTimeout, CompressionStream, console, CountQueuingStrategy, Crypto, CryptoKey, CustomEvent, DecompressionStream, Event, EventTarget, exports, fetch, File, FormData, global, Headers, MessageChannel, MessageEvent, MessagePort, module, PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceObserver, performance, process, queueMicrotask, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, require, Response, Request, setImmediate, setInterval, setTimeout, structuredClone, SubtleCrypto, DOMException, TextDecoder, TextDecoderStream, TextEncoder, TextEncoderStream, TransformStream, TransformStreamDefaultController, URL, URLSearchParams, WebAssembly, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter. The globals PerformanceObserverEntryList and PerformanceResourceTiming are not supported.

__dirname and __filename availability in CommonJS and ES modules

__dirname and __filename are CommonJS globals available inside CommonJS modules in the npm package scope, but they are not defined in ES modules. In own ES modules, use import.meta.dirname and import.meta.filename instead, which provide the same values for the current module.

node:worker_threads improvements in Deno 2.7

Deno 2.7 significantly improved node:worker_threads compatibility. stdout and stderr streams are forwarded correctly from workers to the parent process. worker.terminate() now resolves with the correct exit code. workerData, execArgv, and threadName options are supported. worker.performance.eventLoopUtilization() and worker.cpuUsage() are implemented. BroadcastChannel from worker threads is properly ref'd/unref'd.

node:child_process improvements in Deno 2.7

Deno 2.7 improved node:child_process compatibility. stdio streams (stdin, stdout, stderr) are exposed as Socket instances, matching Node.js behavior. Shell redirection (>, <, >>) works in exec() and execSync(). fork() accepts a URL as the module path. timeout and killSignal options are supported in exec() and spawn(). NODE_OPTIONS environment variable is respected for fork()'d processes.

node:zlib Zstd compression support in Deno 2.7

Deno 2.7 added Zstd compression support to node:zlib with functions zlib.zstdCompress(), zlib.zstdDecompress(), zlib.zstdCompressSync(), and zlib.zstdDecompressSync().

node:zlib Zstd compression example

Example of using Zstd compression in node:zlib: import zlib from "node:zlib"; import { promisify } from "node:util"; const compress = promisify(zlib.zstdCompress); const decompress = promisify(zlib.zstdDecompress); const compressed = await compress(Buffer.from("Hello, Deno!")); const result = await decompress(compressed); console.log(result.toString()); // "Hello, Deno!"

DatabaseSync.setAuthorizer() for node:sqlite

DatabaseSync.setAuthorizer(callback) registers a callback invoked for every SQL operation, enabling fine-grained access control over which tables and operations are permitted.

DatabaseSync.setAuthorizer() example

Example of using setAuthorizer in node:sqlite: import { constants, DatabaseSync } from "node:sqlite"; const db = new DatabaseSync(":memory:"); db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)"); db.setAuthorizer((_action, _table) => { return constants.SQLITE_OK; });

DatabaseSync.enableDefensive() for node:sqlite

DatabaseSync.enableDefensive(enabled) enables or disables defensive mode, which prevents potentially dangerous database operations such as schema modifications at runtime.

DatabaseSync.createTagStore() for node:sqlite

DatabaseSync.createTagStore() creates a prepared-statement cache that maps SQL strings to compiled statements for efficient repeated execution.

Give your agent this brain