Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions types/node/assert.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* The `node:assert` module provides a set of assertion functions for verifying
* invariants.
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/assert.js)
*/
declare module "node:assert" {
import strict = require("node:assert/strict");
/**
Expand Down
46 changes: 0 additions & 46 deletions types/node/assert/strict.d.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,3 @@
/**
* In strict assertion mode, non-strict methods behave like their corresponding
* strict methods. For example, `assert.deepEqual()` will behave like
* `assert.deepStrictEqual()`.
*
* In strict assertion mode, error messages for objects display a diff. In legacy
* assertion mode, error messages for objects display the objects, often truncated.
*
* To use strict assertion mode:
*
* ```js
* import { strict as assert } from 'node:assert';
* ```
*
* ```js
* import assert from 'node:assert/strict';
* ```
*
* Example error diff:
*
* ```js
* import { strict as assert } from 'node:assert';
*
* assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
* // AssertionError: Expected inputs to be strictly deep-equal:
* // + actual - expected ... Lines skipped
* //
* // [
* // [
* // ...
* // 2,
* // + 3
* // - '3'
* // ],
* // ...
* // 5
* // ]
* ```
*
* To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS`
* environment variables. This will also deactivate the colors in the REPL. For
* more on color support in terminal environments, read the tty
* [`getColorDepth()`](https://nodejs.org/docs/latest-v25.x/api/tty.html#writestreamgetcolordepthenv) documentation.
* @since v15.0.0
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/assert/strict.js)
*/
declare module "node:assert/strict" {
import {
Assert,
Expand Down
56 changes: 18 additions & 38 deletions types/node/async_hooks.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/**
* We strongly discourage the use of the `async_hooks` API.
* Other APIs that can cover most of its use cases include:
*
* * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v25.x/api/async_context.html#class-asynclocalstorage) tracks async context
* * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
*
* The `node:async_hooks` module provides an API to track asynchronous resources.
* It can be accessed using:
*
* ```js
* import async_hooks from 'node:async_hooks';
* ```
* @experimental
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/async_hooks.js)
*/
declare module "node:async_hooks" {
/**
* ```js
Expand Down Expand Up @@ -123,37 +107,31 @@ declare module "node:async_hooks" {
function triggerAsyncId(): number;
interface HookCallbacks {
/**
* Called when a class is constructed that has the possibility to emit an asynchronous event.
* @param asyncId A unique ID for the async resource
* @param type The type of the async resource
* @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
* @param resource Reference to the resource representing the async operation, needs to be released during destroy
* The [`init` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#initasyncid-type-triggerasyncid-resource).
*/
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
/**
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
* The before callback is called just before said callback is executed.
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
* The [`before` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#beforeasyncid).
*/
before?(asyncId: number): void;
/**
* Called immediately after the callback specified in `before` is completed.
*
* If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
* The [`after` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#afterasyncid).
*/
after?(asyncId: number): void;
/**
* Called when a promise has resolve() called. This may not be in the same execution id
* as the promise itself.
* @param asyncId the unique id for the promise that was resolve()d.
* The [`promiseResolve` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promiseresolveasyncid).
*/
promiseResolve?(asyncId: number): void;
/**
* Called after the resource corresponding to asyncId is destroyed
* @param asyncId a unique ID for the async resource
* The [`destroy` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#destroyasyncid).
*/
destroy?(asyncId: number): void;
/**
* Whether the hook should track `Promise`s. Cannot be `false` if
* `promiseResolve` is set.
* @default true
*/
trackPromises?: boolean | undefined;
}
interface AsyncHook {
/**
Expand All @@ -174,7 +152,8 @@ declare module "node:async_hooks" {
*
* All callbacks are optional. For example, if only resource cleanup needs to
* be tracked, then only the `destroy` callback needs to be passed. The
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
* specifics of all functions that can be passed to `callbacks` is in the
* [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) section.
*
* ```js
* import { createHook } from 'node:async_hooks';
Expand Down Expand Up @@ -202,12 +181,13 @@ declare module "node:async_hooks" {
* ```
*
* Because promises are asynchronous resources whose lifecycle is tracked
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and
* `destroy()` callbacks _must not_ be async functions that return promises.
* @since v8.1.0
* @param callbacks The `Hook Callbacks` to register
* @return Instance used for disabling and enabling hooks
* @param options The [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) to register
* @returns Instance used for disabling and enabling hooks
*/
function createHook(callbacks: HookCallbacks): AsyncHook;
function createHook(options: HookCallbacks): AsyncHook;
interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
Expand Down
2 changes: 1 addition & 1 deletion types/node/buffer.buffer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ declare module "node:buffer" {
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
* in `list` by adding their lengths.
*
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
* If `totalLength` is provided, it must be an unsigned integer. If the
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
* truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
* less than `totalLength`, the remaining space is filled with zeros.
Expand Down
45 changes: 0 additions & 45 deletions types/node/buffer.d.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
/**
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
* Node.js APIs support `Buffer`s.
*
* The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and
* extends it with methods that cover additional use cases. Node.js APIs accept
* plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.
*
* While the `Buffer` class is available within the global scope, it is still
* recommended to explicitly reference it via an import or require statement.
*
* ```js
* import { Buffer } from 'node:buffer';
*
* // Creates a zero-filled Buffer of length 10.
* const buf1 = Buffer.alloc(10);
*
* // Creates a Buffer of length 10,
* // filled with bytes which all have the value `1`.
* const buf2 = Buffer.alloc(10, 1);
*
* // Creates an uninitialized buffer of length 10.
* // This is faster than calling Buffer.alloc() but the returned
* // Buffer instance might contain old data that needs to be
* // overwritten using fill(), write(), or other functions that fill the Buffer's
* // contents.
* const buf3 = Buffer.allocUnsafe(10);
*
* // Creates a Buffer containing the bytes [1, 2, 3].
* const buf4 = Buffer.from([1, 2, 3]);
*
* // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
* // are all truncated using `(value & 255)` to fit into the range 0–255.
* const buf5 = Buffer.from([257, 257.5, -255, '1']);
*
* // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
* // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
* // [116, 195, 169, 115, 116] (in decimal notation)
* const buf6 = Buffer.from('tést');
*
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
* const buf7 = Buffer.from('tést', 'latin1');
* ```
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/buffer.js)
*/
declare module "node:buffer" {
import { ReadableStream } from "node:stream/web";
/**
Expand Down
67 changes: 0 additions & 67 deletions types/node/child_process.d.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,3 @@
/**
* The `node:child_process` module provides the ability to spawn subprocesses in
* a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
* is primarily provided by the {@link spawn} function:
*
* ```js
* import { spawn } from 'node:child_process';
* import { once } from 'node:events';
* const ls = spawn('ls', ['-lh', '/usr']);
*
* ls.stdout.on('data', (data) => {
* console.log(`stdout: ${data}`);
* });
*
* ls.stderr.on('data', (data) => {
* console.error(`stderr: ${data}`);
* });
*
* const [code] = await once(ls, 'close');
* console.log(`child process exited with code ${code}`);
* ```
*
* By default, pipes for `stdin`, `stdout`, and `stderr` are established between
* the parent Node.js process and the spawned subprocess. These pipes have
* limited (and platform-specific) capacity. If the subprocess writes to
* stdout in excess of that limit without the output being captured, the
* subprocess blocks, waiting for the pipe buffer to accept more data. This is
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed.
*
* The command lookup is performed using the `options.env.PATH` environment
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
* used. If `options.env` is set without `PATH`, lookup on Unix is performed
* on a default search path search of `/usr/bin:/bin` (see your operating system's
* manual for execvpe/execvp), on Windows the current processes environment
* variable `PATH` is used.
*
* On Windows, environment variables are case-insensitive. Node.js
* lexicographically sorts the `env` keys and uses the first one that
* case-insensitively matches. Only first (in lexicographic order) entry will be
* passed to the subprocess. This might lead to issues on Windows when passing
* objects to the `env` option that have multiple variants of the same key, such as `PATH` and `Path`.
*
* The {@link spawn} method spawns the child process asynchronously,
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
* the event loop until the spawned process either exits or is terminated.
*
* For convenience, the `node:child_process` module provides a handful of
* synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
* top of {@link spawn} or {@link spawnSync}.
*
* * {@link exec}: spawns a shell and runs a command within that
* shell, passing the `stdout` and `stderr` to a callback function when
* complete.
* * {@link execFile}: similar to {@link exec} except
* that it spawns the command directly without first spawning a shell by
* default.
* * {@link fork}: spawns a new Node.js process and invokes a
* specified module with an IPC communication channel established that allows
* sending messages between parent and child.
* * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop.
* * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop.
*
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
* the synchronous methods can have significant impact on performance due to
* stalling the event loop while spawned processes complete.
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/child_process.js)
*/
declare module "node:child_process" {
import { NonSharedBuffer } from "node:buffer";
import * as dgram from "node:dgram";
Expand Down
54 changes: 0 additions & 54 deletions types/node/cluster.d.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
/**
* Clusters of Node.js processes can be used to run multiple instances of Node.js
* that can distribute workloads among their application threads. When process isolation
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html)
* module instead, which allows running multiple application threads within a single Node.js instance.
*
* The cluster module allows easy creation of child processes that all share
* server ports.
*
* ```js
* import cluster from 'node:cluster';
* import http from 'node:http';
* import { availableParallelism } from 'node:os';
* import process from 'node:process';
*
* const numCPUs = availableParallelism();
*
* if (cluster.isPrimary) {
* console.log(`Primary ${process.pid} is running`);
*
* // Fork workers.
* for (let i = 0; i < numCPUs; i++) {
* cluster.fork();
* }
*
* cluster.on('exit', (worker, code, signal) => {
* console.log(`worker ${worker.process.pid} died`);
* });
* } else {
* // Workers can share any TCP connection
* // In this case it is an HTTP server
* http.createServer((req, res) => {
* res.writeHead(200);
* res.end('hello world\n');
* }).listen(8000);
*
* console.log(`Worker ${process.pid} started`);
* }
* ```
*
* Running Node.js will now share port 8000 between the workers:
*
* ```console
* $ node server.js
* Primary 3596 is running
* Worker 4324 started
* Worker 4520 started
* Worker 6056 started
* Worker 5644 started
* ```
*
* On Windows, it is not yet possible to set up a named pipe server in a worker.
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/cluster.js)
*/
declare module "node:cluster" {
import * as child_process from "node:child_process";
import { EventEmitter, InternalEventEmitter } from "node:events";
Expand Down
Loading