Skip to content

Commit

Permalink
Split node/v8 and node/v9
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Apr 17, 2019
1 parent 64003b1 commit f2fca64
Show file tree
Hide file tree
Showing 90 changed files with 23,531 additions and 15,086 deletions.
40 changes: 40 additions & 0 deletions types/node/v8/assert.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
declare module "assert" {
function internal(value: any, message?: string): void;
namespace internal {
export class AssertionError implements Error {
name: string;
message: string;
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';

constructor(options?: {
message?: string; actual?: any; expected?: any;
operator?: string; stackStartFn?: Function
});
}

export function fail(message?: string): never;
export function fail(actual: any, expected: any, message?: string, operator?: string, stackStartFn?: Function): never;
export function ok(value: any, message?: string): void;
export function equal(actual: any, expected: any, message?: string): void;
export function notEqual(actual: any, expected: any, message?: string): void;
export function deepEqual(actual: any, expected: any, message?: string): void;
export function notDeepEqual(actual: any, expected: any, message?: string): void;
export function strictEqual(actual: any, expected: any, message?: string): void;
export function notStrictEqual(actual: any, expected: any, message?: string): void;
export function deepStrictEqual(actual: any, expected: any, message?: string): void;
export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;

export function throws(block: Function, message?: string): void;
export function throws(block: Function, error: RegExp | Function, message?: string): void;
export function doesNotThrow(block: Function, message?: string): void;
export function doesNotThrow(block: Function, error: RegExp | Function, message?: string): void;

export function ifError(value: any): void;
}

export = internal;
}
133 changes: 133 additions & 0 deletions types/node/v8/async_hooks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* Async Hooks module: https://nodejs.org/api/async_hooks.html
*/
declare module "async_hooks" {
/**
* Returns the asyncId of the current execution context.
*/
export function executionAsyncId(): number;
/// @deprecated - replaced by executionAsyncId()
export function currentId(): number;

/**
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
*/
export function triggerAsyncId(): number;
/// @deprecated - replaced by triggerAsyncId()
export function triggerId(): number;

export 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
*/
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.
*/
before?(asyncId: number): void;

/**
* Called immediately after the callback specified in before is completed.
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
*/
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.
*/
promiseResolve?(asyncId: number): void;

/**
* Called after the resource corresponding to asyncId is destroyed
* @param asyncId a unique ID for the async resource
*/
destroy?(asyncId: number): void;
}

export interface AsyncHook {
/**
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
*/
enable(): this;

/**
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
*/
disable(): this;
}

/**
* Registers functions to be called for different lifetime events of each async operation.
* @param options the callbacks to register
* @return an AsyncHooks instance used for disabling and enabling hooks
*/
export function createHook(options: HookCallbacks): AsyncHook;

export interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;

/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}

/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
*/
export class AsyncResource {
/**
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 8.10)
*/
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);

/**
* Call AsyncHooks before callbacks.
*/
emitBefore(): void;

/**
* Call AsyncHooks after callbacks
*/
emitAfter(): void;

/**
* Call AsyncHooks destroy callbacks.
*/
emitDestroy(): void;

/**
* @return the unique ID assigned to this AsyncResource instance.
*/
asyncId(): number;

/**
* @return the trigger ID for this AsyncResource instance.
*/
triggerAsyncId(): number;
}
}
39 changes: 39 additions & 0 deletions types/node/v8/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// base definitions for all NodeJS modules that are not specific to any version of TypeScript
/// <reference path="inspector.d.ts" />
/// <reference path="globals.d.ts" />
/// <reference path="buffer.d.ts" />
/// <reference path="querystring.d.ts" />
/// <reference path="events.d.ts" />
/// <reference path="http.d.ts" />
/// <reference path="cluster.d.ts" />
/// <reference path="zlib.d.ts" />
/// <reference path="os.d.ts" />
/// <reference path="https.d.ts" />
/// <reference path="punycode.d.ts" />
/// <reference path="repl.d.ts" />
/// <reference path="readline.d.ts" />
/// <reference path="vm.d.ts" />
/// <reference path="child_process.d.ts" />
/// <reference path="url.d.ts" />
/// <reference path="dns.d.ts" />
/// <reference path="net.d.ts" />
/// <reference path="dgram.d.ts" />
/// <reference path="fs.d.ts" />
/// <reference path="path.d.ts" />
/// <reference path="string_decoder.d.ts" />
/// <reference path="tls.d.ts" />
/// <reference path="crypto.d.ts" />
/// <reference path="stream.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="assert.d.ts" />
/// <reference path="tty.d.ts" />
/// <reference path="domain.d.ts" />
/// <reference path="constants.d.ts" />
/// <reference path="module.d.ts" />
/// <reference path="process.d.ts" />
/// <reference path="v8.d.ts" />
/// <reference path="timers.d.ts" />
/// <reference path="console.d.ts" />
/// <reference path="async_hooks.d.ts" />
/// <reference path="http2.d.ts" />
/// <reference path="perf_hooks.d.ts" />
13 changes: 13 additions & 0 deletions types/node/v8/buffer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/************************************************
* *
* MODULES *
* *
************************************************/
declare module "buffer" {
export var INSPECT_MAX_BYTES: number;
var BuffType: typeof Buffer;
var SlowBuffType: typeof SlowBuffer;
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export { BuffType as Buffer, SlowBuffType as SlowBuffer };
}

0 comments on commit f2fca64

Please sign in to comment.