@types/node
Advanced tools
Comparing version
@@ -231,2 +231,12 @@ /** | ||
/** | ||
* @since v18.8.0, v16.19.0 | ||
* @return Number of bytes queued for sending. | ||
*/ | ||
getSendQueueSize(): number; | ||
/** | ||
* @since v18.8.0, v16.19.0 | ||
* @return Number of send requests currently in the queue awaiting to be processed. | ||
*/ | ||
getSendQueueCount(): number; | ||
/** | ||
* By default, binding a socket will cause it to block the Node.js process from | ||
@@ -233,0 +243,0 @@ * exiting as long as the socket is open. The `socket.unref()` method can be used |
@@ -26,2 +26,3 @@ /** | ||
declare module "diagnostics_channel" { | ||
import { AsyncLocalStorage } from "node:async_hooks"; | ||
/** | ||
@@ -100,2 +101,32 @@ * Check if there are active subscribers to the named channel. This is helpful if | ||
/** | ||
* Creates a `TracingChannel` wrapper for the given `TracingChannel Channels`. If a name is given, the corresponding tracing | ||
* channels will be created in the form of `tracing:${name}:${eventType}` where`eventType` corresponds to the types of `TracingChannel Channels`. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channelsByName = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* // or... | ||
* | ||
* const channelsByCollection = diagnostics_channel.tracingChannel({ | ||
* start: diagnostics_channel.channel('tracing:my-channel:start'), | ||
* end: diagnostics_channel.channel('tracing:my-channel:end'), | ||
* asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'), | ||
* asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'), | ||
* error: diagnostics_channel.channel('tracing:my-channel:error'), | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param nameOrChannels Channel name or object containing all the `TracingChannel Channels` | ||
* @return Collection of channels to trace with | ||
*/ | ||
function tracingChannel< | ||
StoreType = unknown, | ||
ContextType extends object = StoreType extends object ? StoreType : object, | ||
>( | ||
nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>, | ||
): TracingChannel<StoreType, ContextType>; | ||
/** | ||
* The class `Channel` represents an individual named channel within the data | ||
@@ -109,3 +140,3 @@ * pipeline. It is used to track subscribers and to publish messages when there | ||
*/ | ||
class Channel { | ||
class Channel<StoreType = unknown, ContextType = StoreType> { | ||
readonly name: string | symbol; | ||
@@ -190,3 +221,326 @@ /** | ||
unsubscribe(onMessage: ChannelListener): void; | ||
/** | ||
* When `channel.runStores(context, ...)` is called, the given context data | ||
* will be applied to any store bound to the channel. If the store has already been | ||
* bound the previous `transform` function will be replaced with the new one. | ||
* The `transform` function may be omitted to set the given context data as the | ||
* context directly. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store, (data) => { | ||
* return { data }; | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param store The store to which to bind the context data | ||
* @param transform Transform context data before setting the store context | ||
*/ | ||
bindStore(store: AsyncLocalStorage<StoreType>, transform?: (context: ContextType) => StoreType): void; | ||
/** | ||
* Remove a message handler previously registered to this channel with `channel.bindStore(store)`. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store); | ||
* channel.unbindStore(store); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param store The store to unbind from the channel. | ||
* @return `true` if the store was found, `false` otherwise. | ||
*/ | ||
unbindStore(store: any): void; | ||
/** | ||
* Applies the given data to any AsyncLocalStorage instances bound to the channel | ||
* for the duration of the given function, then publishes to the channel within | ||
* the scope of that data is applied to the stores. | ||
* | ||
* If a transform function was given to `channel.bindStore(store)` it will be | ||
* applied to transform the message data before it becomes the context value for | ||
* the store. The prior storage context is accessible from within the transform | ||
* function in cases where context linking is required. | ||
* | ||
* The context applied to the store should be accessible in any async code which | ||
* continues from execution which began during the given function, however | ||
* there are some situations in which `context loss` may occur. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store, (message) => { | ||
* const parent = store.getStore(); | ||
* return new Span(message, parent); | ||
* }); | ||
* channel.runStores({ some: 'message' }, () => { | ||
* store.getStore(); // Span({ some: 'message' }) | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param context Message to send to subscribers and bind to stores | ||
* @param fn Handler to run within the entered storage context | ||
* @param thisArg The receiver to be used for the function call. | ||
* @param args Optional arguments to pass to the function. | ||
*/ | ||
runStores(): void; | ||
} | ||
interface TracingChannelSubscribers<ContextType extends object> { | ||
start: (message: ContextType) => void; | ||
end: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
asyncStart: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
asyncEnd: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
error: ( | ||
message: ContextType & { | ||
error: unknown; | ||
}, | ||
) => void; | ||
} | ||
interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> { | ||
start: Channel<StoreType, ContextType>; | ||
end: Channel<StoreType, ContextType>; | ||
asyncStart: Channel<StoreType, ContextType>; | ||
asyncEnd: Channel<StoreType, ContextType>; | ||
error: Channel<StoreType, ContextType>; | ||
} | ||
/** | ||
* The class `TracingChannel` is a collection of `TracingChannel Channels` which | ||
* together express a single traceable action. It is used to formalize and | ||
* simplify the process of producing events for tracing application flow.{@link tracingChannel} is used to construct a`TracingChannel`. As with `Channel` it is recommended to create and reuse a | ||
* single `TracingChannel` at the top-level of the file rather than creating them | ||
* dynamically. | ||
* @since v19.9.0 | ||
* @experimental | ||
*/ | ||
class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection { | ||
start: Channel<StoreType, ContextType>; | ||
end: Channel<StoreType, ContextType>; | ||
asyncStart: Channel<StoreType, ContextType>; | ||
asyncEnd: Channel<StoreType, ContextType>; | ||
error: Channel<StoreType, ContextType>; | ||
/** | ||
* Helper to subscribe a collection of functions to the corresponding channels. | ||
* This is the same as calling `channel.subscribe(onMessage)` on each channel | ||
* individually. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.subscribe({ | ||
* start(message) { | ||
* // Handle start message | ||
* }, | ||
* end(message) { | ||
* // Handle end message | ||
* }, | ||
* asyncStart(message) { | ||
* // Handle asyncStart message | ||
* }, | ||
* asyncEnd(message) { | ||
* // Handle asyncEnd message | ||
* }, | ||
* error(message) { | ||
* // Handle error message | ||
* }, | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param subscribers Set of `TracingChannel Channels` subscribers | ||
*/ | ||
subscribe(subscribers: TracingChannelSubscribers<ContextType>): void; | ||
/** | ||
* Helper to unsubscribe a collection of functions from the corresponding channels. | ||
* This is the same as calling `channel.unsubscribe(onMessage)` on each channel | ||
* individually. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.unsubscribe({ | ||
* start(message) { | ||
* // Handle start message | ||
* }, | ||
* end(message) { | ||
* // Handle end message | ||
* }, | ||
* asyncStart(message) { | ||
* // Handle asyncStart message | ||
* }, | ||
* asyncEnd(message) { | ||
* // Handle asyncEnd message | ||
* }, | ||
* error(message) { | ||
* // Handle error message | ||
* }, | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param subscribers Set of `TracingChannel Channels` subscribers | ||
* @return `true` if all handlers were successfully unsubscribed, and `false` otherwise. | ||
*/ | ||
unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void; | ||
/** | ||
* Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error. | ||
* This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.traceSync(() => { | ||
* // Do something | ||
* }, { | ||
* some: 'thing', | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn Function to wrap a trace around | ||
* @param context Shared object to correlate events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return The return value of the given function | ||
*/ | ||
traceSync<ThisArg = any, Args extends any[] = any[]>( | ||
fn: (this: ThisArg, ...args: Args) => any, | ||
context?: ContextType, | ||
thisArg?: ThisArg, | ||
...args: Args | ||
): void; | ||
/** | ||
* Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the | ||
* function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also | ||
* produce an `error event` if the given function throws an error or the | ||
* returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.tracePromise(async () => { | ||
* // Do something | ||
* }, { | ||
* some: 'thing', | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn Promise-returning function to wrap a trace around | ||
* @param context Shared object to correlate trace events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return Chained from promise returned by the given function | ||
*/ | ||
tracePromise<ThisArg = any, Args extends any[] = any[]>( | ||
fn: (this: ThisArg, ...args: Args) => Promise<any>, | ||
context?: ContextType, | ||
thisArg?: ThisArg, | ||
...args: Args | ||
): void; | ||
/** | ||
* Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the | ||
* function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or | ||
* the returned | ||
* promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* The `position` will be -1 by default to indicate the final argument should | ||
* be used as the callback. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.traceCallback((arg1, callback) => { | ||
* // Do something | ||
* callback(null, 'result'); | ||
* }, 1, { | ||
* some: 'thing', | ||
* }, thisArg, arg1, callback); | ||
* ``` | ||
* | ||
* The callback will also be run with `channel.runStores(context, ...)` which | ||
* enables context loss recovery in some cases. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* const myStore = new AsyncLocalStorage(); | ||
* | ||
* // The start channel sets the initial store data to something | ||
* // and stores that store data value on the trace context object | ||
* channels.start.bindStore(myStore, (data) => { | ||
* const span = new Span(data); | ||
* data.span = span; | ||
* return span; | ||
* }); | ||
* | ||
* // Then asyncStart can restore from that data it stored previously | ||
* channels.asyncStart.bindStore(myStore, (data) => { | ||
* return data.span; | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn callback using function to wrap a trace around | ||
* @param position Zero-indexed argument position of expected callback | ||
* @param context Shared object to correlate trace events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return The return value of the given function | ||
*/ | ||
traceCallback<Fn extends (this: any, ...args: any) => any>( | ||
fn: Fn, | ||
position: number | undefined, | ||
context: ContextType | undefined, | ||
thisArg: any, | ||
...args: Parameters<Fn> | ||
): void; | ||
} | ||
} | ||
@@ -193,0 +547,0 @@ declare module "node:diagnostics_channel" { |
@@ -237,2 +237,28 @@ export {}; // Make this a module | ||
isConstructor(): boolean; | ||
/** | ||
* is this an async call (i.e. await, Promise.all(), or Promise.any())? | ||
*/ | ||
isAsync(): boolean; | ||
/** | ||
* is this an async call to Promise.all()? | ||
*/ | ||
isPromiseAll(): boolean; | ||
/** | ||
* returns the index of the promise element that was followed in | ||
* Promise.all() or Promise.any() for async stack traces, or null | ||
* if the CallSite is not an async | ||
*/ | ||
getPromiseIndex(): number | null; | ||
getScriptNameOrSourceURL(): string; | ||
getScriptHash(): string; | ||
getEnclosingColumnNumber(): number; | ||
getEnclosingLineNumber(): number; | ||
getPosition(): number; | ||
toString(): string; | ||
} | ||
@@ -239,0 +265,0 @@ |
@@ -279,2 +279,16 @@ /** | ||
interface ImportMeta { | ||
/** | ||
* The directory name of the current module. This is the same as the `path.dirname()` of the `import.meta.filename`. | ||
* **Caveat:** only present on `file:` modules. | ||
*/ | ||
dirname?: string; | ||
/** | ||
* The full absolute path and filename of the current module, with symlinks resolved. | ||
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`. | ||
* **Caveat:** only local modules support this property. Modules not using the `file:` protocol will not provide it. | ||
*/ | ||
filename?: string; | ||
/** | ||
* The absolute `file:` URL of the module. | ||
*/ | ||
url: string; | ||
@@ -281,0 +295,0 @@ /** |
{ | ||
"name": "@types/node", | ||
"version": "20.10.3", | ||
"version": "20.11.0", | ||
"description": "TypeScript definitions for node", | ||
@@ -227,5 +227,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node", | ||
}, | ||
"typesPublisherContentHash": "23bf5e20c3e989ac01a5ead7a9bd16b7752ee61c6293df790619aa6185433385", | ||
"typesPublisherContentHash": "ca77e7986f304692dfe04a1ec38a5dbebe32e569398b09ae4d01fd359a652186", | ||
"typeScriptVersion": "4.6", | ||
"nonNpm": true | ||
} |
@@ -317,3 +317,4 @@ /** | ||
* * startTime: 81.465639, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * }, | ||
@@ -324,3 +325,4 @@ * * PerformanceEntry { | ||
* * startTime: 81.860064, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -360,3 +362,4 @@ * * ] | ||
* * startTime: 98.545991, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -374,3 +377,4 @@ * * ] | ||
* * startTime: 63.518931, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -411,3 +415,4 @@ * * ] | ||
* * startTime: 55.897834, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * }, | ||
@@ -418,3 +423,4 @@ * * PerformanceEntry { | ||
* * startTime: 56.350146, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -421,0 +427,0 @@ * * ] |
@@ -77,6 +77,6 @@ /** | ||
* | ||
* ```js | ||
* ```json | ||
* { | ||
* foo: 'bar', | ||
* abc: ['xyz', '123'] | ||
* "foo": "bar", | ||
* "abc": ["xyz", "123"] | ||
* } | ||
@@ -83,0 +83,0 @@ * ``` |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Sun, 03 Dec 2023 18:07:12 GMT | ||
* Last updated: Thu, 11 Jan 2024 05:35:20 GMT | ||
* Dependencies: [undici-types](https://npmjs.com/package/undici-types) | ||
@@ -14,0 +14,0 @@ |
@@ -85,2 +85,7 @@ /** | ||
/** | ||
* **Note:**`shard` is used to horizontally parallelize test running across | ||
* machines or processes, ideal for large-scale executions across varied | ||
* environments. It's incompatible with `watch` mode, tailored for rapid | ||
* code iteration by automatically rerunning tests on file changes. | ||
* | ||
* ```js | ||
@@ -1017,2 +1022,4 @@ * import { tap } from 'node:test/reporters'; | ||
* | ||
* MockTimers is also able to mock the `Date` object. | ||
* | ||
* The `MockTracker` provides a top-level `timers` export | ||
@@ -1030,7 +1037,10 @@ * which is a `MockTimers` instance. | ||
* | ||
* Example usage: | ||
* **Note:** Mocking `Date` will affect the behavior of the mocked timers | ||
* as they use the same internal clock. | ||
* | ||
* Example usage without setting initial time: | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable(['setInterval']); | ||
* mock.timers.enable({ apis: ['setInterval'] }); | ||
* ``` | ||
@@ -1041,2 +1051,16 @@ * | ||
* | ||
* Example usage with initial time set | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['Date'], now: 1000 }); | ||
* ``` | ||
* | ||
* Example usage with initial Date object as time set | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['Date'], now: new Date() }); | ||
* ``` | ||
* | ||
* Alternatively, if you call `mock.timers.enable()` without any parameters: | ||
@@ -1046,3 +1070,3 @@ * | ||
* will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. | ||
* and `globalThis` will be mocked. As well as the global `Date` object. | ||
* @since v20.4.0 | ||
@@ -1084,3 +1108,3 @@ */ | ||
* | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout'] }); | ||
* | ||
@@ -1106,3 +1130,3 @@ * setTimeout(fn, 9999); | ||
* const fn = context.mock.fn(); | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout'] }); | ||
* const nineSecs = 9000; | ||
@@ -1119,2 +1143,25 @@ * setTimeout(fn, nineSecs); | ||
* ``` | ||
* | ||
* Advancing time using `.tick` will also advance the time for any `Date` object | ||
* created after the mock was enabled (if `Date` was also set to be mocked). | ||
* | ||
* ```js | ||
* import assert from 'node:assert'; | ||
* import { test } from 'node:test'; | ||
* | ||
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { | ||
* const fn = context.mock.fn(); | ||
* | ||
* context.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); | ||
* setTimeout(fn, 9999); | ||
* | ||
* assert.strictEqual(fn.mock.callCount(), 0); | ||
* assert.strictEqual(Date.now(), 0); | ||
* | ||
* // Advance in time | ||
* context.mock.timers.tick(9999); | ||
* assert.strictEqual(fn.mock.callCount(), 1); | ||
* assert.strictEqual(Date.now(), 9999); | ||
* }); | ||
* ``` | ||
* @since v20.4.0 | ||
@@ -1124,3 +1171,4 @@ */ | ||
/** | ||
* Triggers all pending mocked timers immediately. | ||
* Triggers all pending mocked timers immediately. If the `Date` object is also | ||
* mocked, it will also advance the `Date` object to the furthest timer's time. | ||
* | ||
@@ -1135,3 +1183,3 @@ * The example below triggers all pending timers immediately, | ||
* test('runAll functions following the given order', (context) => { | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); | ||
* const results = []; | ||
@@ -1148,4 +1196,5 @@ * setTimeout(() => results.push(1), 9999); | ||
* context.mock.timers.runAll(); | ||
* | ||
* assert.deepStrictEqual(results, [3, 2, 1]); | ||
* // The Date object is also advanced to the furthest timer's time | ||
* assert.strictEqual(Date.now(), 9999); | ||
* }); | ||
@@ -1357,3 +1406,3 @@ * ``` | ||
declare module "node:test/reporters" { | ||
import { Transform } from "node:stream"; | ||
import { Transform, TransformOptions } from "node:stream"; | ||
@@ -1393,3 +1442,6 @@ type TestEvent = | ||
function junit(source: TestEventGenerator): AsyncGenerator<string, void>; | ||
export { dot, junit, Spec as spec, tap, TestEvent }; | ||
class Lcov extends Transform { | ||
constructor(opts?: TransformOptions); | ||
} | ||
export { dot, junit, Lcov as lcov, Spec as spec, tap, TestEvent }; | ||
} |
@@ -231,2 +231,12 @@ /** | ||
/** | ||
* @since v18.8.0, v16.19.0 | ||
* @return Number of bytes queued for sending. | ||
*/ | ||
getSendQueueSize(): number; | ||
/** | ||
* @since v18.8.0, v16.19.0 | ||
* @return Number of send requests currently in the queue awaiting to be processed. | ||
*/ | ||
getSendQueueCount(): number; | ||
/** | ||
* By default, binding a socket will cause it to block the Node.js process from | ||
@@ -233,0 +243,0 @@ * exiting as long as the socket is open. The `socket.unref()` method can be used |
@@ -26,2 +26,3 @@ /** | ||
declare module "diagnostics_channel" { | ||
import { AsyncLocalStorage } from "node:async_hooks"; | ||
/** | ||
@@ -100,2 +101,32 @@ * Check if there are active subscribers to the named channel. This is helpful if | ||
/** | ||
* Creates a `TracingChannel` wrapper for the given `TracingChannel Channels`. If a name is given, the corresponding tracing | ||
* channels will be created in the form of `tracing:${name}:${eventType}` where`eventType` corresponds to the types of `TracingChannel Channels`. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channelsByName = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* // or... | ||
* | ||
* const channelsByCollection = diagnostics_channel.tracingChannel({ | ||
* start: diagnostics_channel.channel('tracing:my-channel:start'), | ||
* end: diagnostics_channel.channel('tracing:my-channel:end'), | ||
* asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'), | ||
* asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'), | ||
* error: diagnostics_channel.channel('tracing:my-channel:error'), | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param nameOrChannels Channel name or object containing all the `TracingChannel Channels` | ||
* @return Collection of channels to trace with | ||
*/ | ||
function tracingChannel< | ||
StoreType = unknown, | ||
ContextType extends object = StoreType extends object ? StoreType : object, | ||
>( | ||
nameOrChannels: string | TracingChannelCollection<StoreType, ContextType>, | ||
): TracingChannel<StoreType, ContextType>; | ||
/** | ||
* The class `Channel` represents an individual named channel within the data | ||
@@ -109,3 +140,3 @@ * pipeline. It is used to track subscribers and to publish messages when there | ||
*/ | ||
class Channel { | ||
class Channel<StoreType = unknown, ContextType = StoreType> { | ||
readonly name: string | symbol; | ||
@@ -190,3 +221,326 @@ /** | ||
unsubscribe(onMessage: ChannelListener): void; | ||
/** | ||
* When `channel.runStores(context, ...)` is called, the given context data | ||
* will be applied to any store bound to the channel. If the store has already been | ||
* bound the previous `transform` function will be replaced with the new one. | ||
* The `transform` function may be omitted to set the given context data as the | ||
* context directly. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store, (data) => { | ||
* return { data }; | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param store The store to which to bind the context data | ||
* @param transform Transform context data before setting the store context | ||
*/ | ||
bindStore(store: AsyncLocalStorage<StoreType>, transform?: (context: ContextType) => StoreType): void; | ||
/** | ||
* Remove a message handler previously registered to this channel with `channel.bindStore(store)`. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store); | ||
* channel.unbindStore(store); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param store The store to unbind from the channel. | ||
* @return `true` if the store was found, `false` otherwise. | ||
*/ | ||
unbindStore(store: any): void; | ||
/** | ||
* Applies the given data to any AsyncLocalStorage instances bound to the channel | ||
* for the duration of the given function, then publishes to the channel within | ||
* the scope of that data is applied to the stores. | ||
* | ||
* If a transform function was given to `channel.bindStore(store)` it will be | ||
* applied to transform the message data before it becomes the context value for | ||
* the store. The prior storage context is accessible from within the transform | ||
* function in cases where context linking is required. | ||
* | ||
* The context applied to the store should be accessible in any async code which | ||
* continues from execution which began during the given function, however | ||
* there are some situations in which `context loss` may occur. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const store = new AsyncLocalStorage(); | ||
* | ||
* const channel = diagnostics_channel.channel('my-channel'); | ||
* | ||
* channel.bindStore(store, (message) => { | ||
* const parent = store.getStore(); | ||
* return new Span(message, parent); | ||
* }); | ||
* channel.runStores({ some: 'message' }, () => { | ||
* store.getStore(); // Span({ some: 'message' }) | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param context Message to send to subscribers and bind to stores | ||
* @param fn Handler to run within the entered storage context | ||
* @param thisArg The receiver to be used for the function call. | ||
* @param args Optional arguments to pass to the function. | ||
*/ | ||
runStores(): void; | ||
} | ||
interface TracingChannelSubscribers<ContextType extends object> { | ||
start: (message: ContextType) => void; | ||
end: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
asyncStart: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
asyncEnd: ( | ||
message: ContextType & { | ||
error?: unknown; | ||
result?: unknown; | ||
}, | ||
) => void; | ||
error: ( | ||
message: ContextType & { | ||
error: unknown; | ||
}, | ||
) => void; | ||
} | ||
interface TracingChannelCollection<StoreType = unknown, ContextType = StoreType> { | ||
start: Channel<StoreType, ContextType>; | ||
end: Channel<StoreType, ContextType>; | ||
asyncStart: Channel<StoreType, ContextType>; | ||
asyncEnd: Channel<StoreType, ContextType>; | ||
error: Channel<StoreType, ContextType>; | ||
} | ||
/** | ||
* The class `TracingChannel` is a collection of `TracingChannel Channels` which | ||
* together express a single traceable action. It is used to formalize and | ||
* simplify the process of producing events for tracing application flow.{@link tracingChannel} is used to construct a`TracingChannel`. As with `Channel` it is recommended to create and reuse a | ||
* single `TracingChannel` at the top-level of the file rather than creating them | ||
* dynamically. | ||
* @since v19.9.0 | ||
* @experimental | ||
*/ | ||
class TracingChannel<StoreType = unknown, ContextType extends object = {}> implements TracingChannelCollection { | ||
start: Channel<StoreType, ContextType>; | ||
end: Channel<StoreType, ContextType>; | ||
asyncStart: Channel<StoreType, ContextType>; | ||
asyncEnd: Channel<StoreType, ContextType>; | ||
error: Channel<StoreType, ContextType>; | ||
/** | ||
* Helper to subscribe a collection of functions to the corresponding channels. | ||
* This is the same as calling `channel.subscribe(onMessage)` on each channel | ||
* individually. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.subscribe({ | ||
* start(message) { | ||
* // Handle start message | ||
* }, | ||
* end(message) { | ||
* // Handle end message | ||
* }, | ||
* asyncStart(message) { | ||
* // Handle asyncStart message | ||
* }, | ||
* asyncEnd(message) { | ||
* // Handle asyncEnd message | ||
* }, | ||
* error(message) { | ||
* // Handle error message | ||
* }, | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param subscribers Set of `TracingChannel Channels` subscribers | ||
*/ | ||
subscribe(subscribers: TracingChannelSubscribers<ContextType>): void; | ||
/** | ||
* Helper to unsubscribe a collection of functions from the corresponding channels. | ||
* This is the same as calling `channel.unsubscribe(onMessage)` on each channel | ||
* individually. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.unsubscribe({ | ||
* start(message) { | ||
* // Handle start message | ||
* }, | ||
* end(message) { | ||
* // Handle end message | ||
* }, | ||
* asyncStart(message) { | ||
* // Handle asyncStart message | ||
* }, | ||
* asyncEnd(message) { | ||
* // Handle asyncEnd message | ||
* }, | ||
* error(message) { | ||
* // Handle error message | ||
* }, | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param subscribers Set of `TracingChannel Channels` subscribers | ||
* @return `true` if all handlers were successfully unsubscribed, and `false` otherwise. | ||
*/ | ||
unsubscribe(subscribers: TracingChannelSubscribers<ContextType>): void; | ||
/** | ||
* Trace a synchronous function call. This will always produce a `start event` and `end event` around the execution and may produce an `error event` if the given function throws an error. | ||
* This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.traceSync(() => { | ||
* // Do something | ||
* }, { | ||
* some: 'thing', | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn Function to wrap a trace around | ||
* @param context Shared object to correlate events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return The return value of the given function | ||
*/ | ||
traceSync<ThisArg = any, Args extends any[] = any[]>( | ||
fn: (this: ThisArg, ...args: Args) => any, | ||
context?: ContextType, | ||
thisArg?: ThisArg, | ||
...args: Args | ||
): void; | ||
/** | ||
* Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the | ||
* function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also | ||
* produce an `error event` if the given function throws an error or the | ||
* returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.tracePromise(async () => { | ||
* // Do something | ||
* }, { | ||
* some: 'thing', | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn Promise-returning function to wrap a trace around | ||
* @param context Shared object to correlate trace events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return Chained from promise returned by the given function | ||
*/ | ||
tracePromise<ThisArg = any, Args extends any[] = any[]>( | ||
fn: (this: ThisArg, ...args: Args) => Promise<any>, | ||
context?: ContextType, | ||
thisArg?: ThisArg, | ||
...args: Args | ||
): void; | ||
/** | ||
* Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the | ||
* function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or | ||
* the returned | ||
* promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all | ||
* events should have any bound stores set to match this trace context. | ||
* | ||
* The `position` will be -1 by default to indicate the final argument should | ||
* be used as the callback. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* | ||
* channels.traceCallback((arg1, callback) => { | ||
* // Do something | ||
* callback(null, 'result'); | ||
* }, 1, { | ||
* some: 'thing', | ||
* }, thisArg, arg1, callback); | ||
* ``` | ||
* | ||
* The callback will also be run with `channel.runStores(context, ...)` which | ||
* enables context loss recovery in some cases. | ||
* | ||
* ```js | ||
* import diagnostics_channel from 'node:diagnostics_channel'; | ||
* import { AsyncLocalStorage } from 'node:async_hooks'; | ||
* | ||
* const channels = diagnostics_channel.tracingChannel('my-channel'); | ||
* const myStore = new AsyncLocalStorage(); | ||
* | ||
* // The start channel sets the initial store data to something | ||
* // and stores that store data value on the trace context object | ||
* channels.start.bindStore(myStore, (data) => { | ||
* const span = new Span(data); | ||
* data.span = span; | ||
* return span; | ||
* }); | ||
* | ||
* // Then asyncStart can restore from that data it stored previously | ||
* channels.asyncStart.bindStore(myStore, (data) => { | ||
* return data.span; | ||
* }); | ||
* ``` | ||
* @since v19.9.0 | ||
* @experimental | ||
* @param fn callback using function to wrap a trace around | ||
* @param position Zero-indexed argument position of expected callback | ||
* @param context Shared object to correlate trace events through | ||
* @param thisArg The receiver to be used for the function call | ||
* @param args Optional arguments to pass to the function | ||
* @return The return value of the given function | ||
*/ | ||
traceCallback<Fn extends (this: any, ...args: any) => any>( | ||
fn: Fn, | ||
position: number | undefined, | ||
context: ContextType | undefined, | ||
thisArg: any, | ||
...args: Parameters<Fn> | ||
): void; | ||
} | ||
} | ||
@@ -193,0 +547,0 @@ declare module "node:diagnostics_channel" { |
@@ -237,2 +237,28 @@ export {}; // Make this a module | ||
isConstructor(): boolean; | ||
/** | ||
* is this an async call (i.e. await, Promise.all(), or Promise.any())? | ||
*/ | ||
isAsync(): boolean; | ||
/** | ||
* is this an async call to Promise.all()? | ||
*/ | ||
isPromiseAll(): boolean; | ||
/** | ||
* returns the index of the promise element that was followed in | ||
* Promise.all() or Promise.any() for async stack traces, or null | ||
* if the CallSite is not an async | ||
*/ | ||
getPromiseIndex(): number | null; | ||
getScriptNameOrSourceURL(): string; | ||
getScriptHash(): string; | ||
getEnclosingColumnNumber(): number; | ||
getEnclosingLineNumber(): number; | ||
getPosition(): number; | ||
toString(): string; | ||
} | ||
@@ -239,0 +265,0 @@ |
@@ -279,2 +279,16 @@ /** | ||
interface ImportMeta { | ||
/** | ||
* The directory name of the current module. This is the same as the `path.dirname()` of the `import.meta.filename`. | ||
* **Caveat:** only present on `file:` modules. | ||
*/ | ||
dirname?: string; | ||
/** | ||
* The full absolute path and filename of the current module, with symlinks resolved. | ||
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`. | ||
* **Caveat:** only local modules support this property. Modules not using the `file:` protocol will not provide it. | ||
*/ | ||
filename?: string; | ||
/** | ||
* The absolute `file:` URL of the module. | ||
*/ | ||
url: string; | ||
@@ -281,0 +295,0 @@ /** |
@@ -34,3 +34,3 @@ /** | ||
import { AsyncResource } from "node:async_hooks"; | ||
type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http"; | ||
type EntryType = "node" | "mark" | "measure" | "gc" | "function" | "http2" | "http" | "dns" | "net"; | ||
interface NodeGCPerformanceDetail { | ||
@@ -318,3 +318,4 @@ /** | ||
* * startTime: 81.465639, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * }, | ||
@@ -325,3 +326,4 @@ * * PerformanceEntry { | ||
* * startTime: 81.860064, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -361,3 +363,4 @@ * * ] | ||
* * startTime: 98.545991, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -375,3 +378,4 @@ * * ] | ||
* * startTime: 63.518931, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -412,3 +416,4 @@ * * ] | ||
* * startTime: 55.897834, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * }, | ||
@@ -419,3 +424,4 @@ * * PerformanceEntry { | ||
* * startTime: 56.350146, | ||
* * duration: 0 | ||
* * duration: 0, | ||
* * detail: null | ||
* * } | ||
@@ -422,0 +428,0 @@ * * ] |
@@ -77,6 +77,6 @@ /** | ||
* | ||
* ```js | ||
* ```json | ||
* { | ||
* foo: 'bar', | ||
* abc: ['xyz', '123'] | ||
* "foo": "bar", | ||
* "abc": ["xyz", "123"] | ||
* } | ||
@@ -83,0 +83,0 @@ * ``` |
@@ -85,2 +85,7 @@ /** | ||
/** | ||
* **Note:**`shard` is used to horizontally parallelize test running across | ||
* machines or processes, ideal for large-scale executions across varied | ||
* environments. It's incompatible with `watch` mode, tailored for rapid | ||
* code iteration by automatically rerunning tests on file changes. | ||
* | ||
* ```js | ||
@@ -1017,2 +1022,4 @@ * import { tap } from 'node:test/reporters'; | ||
* | ||
* MockTimers is also able to mock the `Date` object. | ||
* | ||
* The `MockTracker` provides a top-level `timers` export | ||
@@ -1030,7 +1037,10 @@ * which is a `MockTimers` instance. | ||
* | ||
* Example usage: | ||
* **Note:** Mocking `Date` will affect the behavior of the mocked timers | ||
* as they use the same internal clock. | ||
* | ||
* Example usage without setting initial time: | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable(['setInterval']); | ||
* mock.timers.enable({ apis: ['setInterval'] }); | ||
* ``` | ||
@@ -1041,2 +1051,16 @@ * | ||
* | ||
* Example usage with initial time set | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['Date'], now: 1000 }); | ||
* ``` | ||
* | ||
* Example usage with initial Date object as time set | ||
* | ||
* ```js | ||
* import { mock } from 'node:test'; | ||
* mock.timers.enable({ apis: ['Date'], now: new Date() }); | ||
* ``` | ||
* | ||
* Alternatively, if you call `mock.timers.enable()` without any parameters: | ||
@@ -1046,3 +1070,3 @@ * | ||
* will be mocked. The `setInterval`, `clearInterval`, `setTimeout`, and `clearTimeout`functions from `node:timers`, `node:timers/promises`, | ||
* and `globalThis` will be mocked. | ||
* and `globalThis` will be mocked. As well as the global `Date` object. | ||
* @since v20.4.0 | ||
@@ -1084,3 +1108,3 @@ */ | ||
* | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout'] }); | ||
* | ||
@@ -1106,3 +1130,3 @@ * setTimeout(fn, 9999); | ||
* const fn = context.mock.fn(); | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout'] }); | ||
* const nineSecs = 9000; | ||
@@ -1119,2 +1143,25 @@ * setTimeout(fn, nineSecs); | ||
* ``` | ||
* | ||
* Advancing time using `.tick` will also advance the time for any `Date` object | ||
* created after the mock was enabled (if `Date` was also set to be mocked). | ||
* | ||
* ```js | ||
* import assert from 'node:assert'; | ||
* import { test } from 'node:test'; | ||
* | ||
* test('mocks setTimeout to be executed synchronously without having to actually wait for it', (context) => { | ||
* const fn = context.mock.fn(); | ||
* | ||
* context.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); | ||
* setTimeout(fn, 9999); | ||
* | ||
* assert.strictEqual(fn.mock.callCount(), 0); | ||
* assert.strictEqual(Date.now(), 0); | ||
* | ||
* // Advance in time | ||
* context.mock.timers.tick(9999); | ||
* assert.strictEqual(fn.mock.callCount(), 1); | ||
* assert.strictEqual(Date.now(), 9999); | ||
* }); | ||
* ``` | ||
* @since v20.4.0 | ||
@@ -1124,3 +1171,4 @@ */ | ||
/** | ||
* Triggers all pending mocked timers immediately. | ||
* Triggers all pending mocked timers immediately. If the `Date` object is also | ||
* mocked, it will also advance the `Date` object to the furthest timer's time. | ||
* | ||
@@ -1135,3 +1183,3 @@ * The example below triggers all pending timers immediately, | ||
* test('runAll functions following the given order', (context) => { | ||
* context.mock.timers.enable(['setTimeout']); | ||
* context.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); | ||
* const results = []; | ||
@@ -1148,4 +1196,5 @@ * setTimeout(() => results.push(1), 9999); | ||
* context.mock.timers.runAll(); | ||
* | ||
* assert.deepStrictEqual(results, [3, 2, 1]); | ||
* // The Date object is also advanced to the furthest timer's time | ||
* assert.strictEqual(Date.now(), 9999); | ||
* }); | ||
@@ -1357,3 +1406,3 @@ * ``` | ||
declare module "node:test/reporters" { | ||
import { Transform } from "node:stream"; | ||
import { Transform, TransformOptions } from "node:stream"; | ||
@@ -1393,3 +1442,6 @@ type TestEvent = | ||
function junit(source: TestEventGenerator): AsyncGenerator<string, void>; | ||
export { dot, junit, Spec as spec, tap, TestEvent }; | ||
class Lcov extends Transform { | ||
constructor(opts?: TransformOptions); | ||
} | ||
export { dot, junit, Lcov as lcov, Spec as spec, tap, TestEvent }; | ||
} |
/** | ||
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives sandboxed WebAssembly applications access to the | ||
* underlying operating system via a collection of POSIX-like functions. | ||
* **The `node:wasi` module does not currently provide the** | ||
* **comprehensive file system security properties provided by some WASI runtimes.** | ||
* **Full support for secure file system sandboxing may or may not be implemented in** | ||
* **future. In the mean time, do not rely on it to run untrusted code.** | ||
* | ||
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives WebAssembly applications access to the underlying | ||
* operating system via a collection of POSIX-like functions. | ||
* | ||
* ```js | ||
@@ -15,3 +20,3 @@ * import { readFile } from 'node:fs/promises'; | ||
* preopens: { | ||
* '/sandbox': '/some/real/path/that/wasm/can/access', | ||
* '/local': '/some/real/path/that/wasm/can/access', | ||
* }, | ||
@@ -121,4 +126,3 @@ * }); | ||
* methods for working with WASI-based applications. Each `WASI` instance | ||
* represents a distinct sandbox environment. For security purposes, each `WASI`instance must have its command-line arguments, environment variables, and | ||
* sandbox directory structure configured explicitly. | ||
* represents a distinct environment. | ||
* @since v13.3.0, v12.16.0 | ||
@@ -125,0 +129,0 @@ */ |
/** | ||
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives sandboxed WebAssembly applications access to the | ||
* underlying operating system via a collection of POSIX-like functions. | ||
* **The `node:wasi` module does not currently provide the** | ||
* **comprehensive file system security properties provided by some WASI runtimes.** | ||
* **Full support for secure file system sandboxing may or may not be implemented in** | ||
* **future. In the mean time, do not rely on it to run untrusted code.** | ||
* | ||
* The WASI API provides an implementation of the [WebAssembly System Interface](https://wasi.dev/) specification. WASI gives WebAssembly applications access to the underlying | ||
* operating system via a collection of POSIX-like functions. | ||
* | ||
* ```js | ||
@@ -15,3 +20,3 @@ * import { readFile } from 'node:fs/promises'; | ||
* preopens: { | ||
* '/sandbox': '/some/real/path/that/wasm/can/access', | ||
* '/local': '/some/real/path/that/wasm/can/access', | ||
* }, | ||
@@ -121,4 +126,3 @@ * }); | ||
* methods for working with WASI-based applications. Each `WASI` instance | ||
* represents a distinct sandbox environment. For security purposes, each `WASI`instance must have its command-line arguments, environment variables, and | ||
* sandbox directory structure configured explicitly. | ||
* represents a distinct environment. | ||
* @since v13.3.0, v12.16.0 | ||
@@ -125,0 +129,0 @@ */ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3973487
1.06%89807
1.06%