mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
feat(node): v13.13 (#43933)
This commit is contained in:
5
types/node/dns.d.ts
vendored
5
types/node/dns.d.ts
vendored
@@ -2,6 +2,11 @@ declare module "dns" {
|
||||
// Supported getaddrinfo flags.
|
||||
const ADDRCONFIG: number;
|
||||
const V4MAPPED: number;
|
||||
/**
|
||||
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
||||
* well as IPv4 mapped IPv6 addresses.
|
||||
*/
|
||||
const ALL: number;
|
||||
|
||||
interface LookupOptions {
|
||||
family?: number;
|
||||
|
||||
52
types/node/fs.d.ts
vendored
52
types/node/fs.d.ts
vendored
@@ -1404,6 +1404,21 @@ declare module "fs" {
|
||||
): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
||||
}
|
||||
|
||||
interface ReadSyncOptions {
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* @default `length of buffer`
|
||||
*/
|
||||
length?: number;
|
||||
/**
|
||||
* @default null
|
||||
*/
|
||||
position?: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously reads data from the file referenced by the supplied file descriptor, returning the number of bytes read.
|
||||
* @param fd A file descriptor.
|
||||
@@ -1414,6 +1429,12 @@ declare module "fs" {
|
||||
*/
|
||||
function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
|
||||
|
||||
/**
|
||||
* Similar to the above `fs.readSync` function, this version takes an optional `options` object.
|
||||
* If no `options` object is specified, it will default with the above values.
|
||||
*/
|
||||
function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
|
||||
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
@@ -2051,6 +2072,32 @@ declare module "fs" {
|
||||
*/
|
||||
function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
|
||||
|
||||
function readv(
|
||||
fd: number,
|
||||
buffers: NodeJS.ArrayBufferView[],
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
|
||||
): void;
|
||||
function readv(
|
||||
fd: number,
|
||||
buffers: NodeJS.ArrayBufferView[],
|
||||
position: number,
|
||||
cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void
|
||||
): void;
|
||||
|
||||
interface ReadVResult {
|
||||
bytesRead: number;
|
||||
buffers: NodeJS.ArrayBufferView[];
|
||||
}
|
||||
|
||||
namespace readv {
|
||||
function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* See `readv`.
|
||||
*/
|
||||
function readvSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
|
||||
|
||||
interface OpenDirOptions {
|
||||
encoding?: BufferEncoding;
|
||||
/**
|
||||
@@ -2202,6 +2249,11 @@ declare module "fs" {
|
||||
*/
|
||||
writev(buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
|
||||
|
||||
/**
|
||||
* See `fs.readv` promisified version.
|
||||
*/
|
||||
readv(buffers: NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
|
||||
|
||||
/**
|
||||
* Asynchronous close(2) - close a `FileHandle`.
|
||||
*/
|
||||
|
||||
7
types/node/globals.d.ts
vendored
7
types/node/globals.d.ts
vendored
@@ -432,6 +432,13 @@ declare namespace NodeJS {
|
||||
customInspect?: boolean;
|
||||
showProxy?: boolean;
|
||||
maxArrayLength?: number | null;
|
||||
/**
|
||||
* Specifies the maximum number of characters to
|
||||
* include when formatting. Set to `null` or `Infinity` to show all elements.
|
||||
* Set to `0` or negative to show no characters.
|
||||
* @default Infinity
|
||||
*/
|
||||
maxStringLength?: number | null;
|
||||
breakLength?: number;
|
||||
/**
|
||||
* Setting this to `false` causes each object key
|
||||
|
||||
2
types/node/http.d.ts
vendored
2
types/node/http.d.ts
vendored
@@ -391,7 +391,7 @@ declare module "http" {
|
||||
|
||||
/**
|
||||
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
||||
* Defaults to 8KB. Configurable using the [`--max-http-header-size`][] CLI option.
|
||||
* Defaults to 16KB. Configurable using the [`--max-http-header-size`][] CLI option.
|
||||
*/
|
||||
const maxHeaderSize: number;
|
||||
}
|
||||
|
||||
2
types/node/index.d.ts
vendored
2
types/node/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for non-npm package Node.js 13.11
|
||||
// Type definitions for non-npm package Node.js 13.13
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as http from "http";
|
||||
import * as https from "https";
|
||||
import * as console2 from "console";
|
||||
import * as timers from "timers";
|
||||
import * as dns from "dns";
|
||||
import * as inspector from "inspector";
|
||||
import * as trace_events from "trace_events";
|
||||
|
||||
@@ -268,119 +267,6 @@ import * as trace_events from "trace_events";
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/// DNS Tests : https://nodejs.org/api/dns.html ///
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
dns.lookup("nodejs.org", (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", 4, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", 6, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup("nodejs.org", {}, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
dns.lookup(
|
||||
"nodejs.org",
|
||||
{
|
||||
family: 4,
|
||||
hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
||||
all: false
|
||||
},
|
||||
(err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
}
|
||||
);
|
||||
dns.lookup("nodejs.org", { all: true }, (err, addresses) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: dns.LookupAddress[] = addresses;
|
||||
});
|
||||
dns.lookup("nodejs.org", { all: true, verbatim: true }, (err, addresses) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: dns.LookupAddress[] = addresses;
|
||||
});
|
||||
|
||||
function trueOrFalse(): boolean {
|
||||
return Math.random() > 0.5 ? true : false;
|
||||
}
|
||||
dns.lookup("nodejs.org", { all: trueOrFalse() }, (err, addresses, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _addresses: string | dns.LookupAddress[] = addresses;
|
||||
const _family: number | undefined = family;
|
||||
});
|
||||
|
||||
dns.lookupService("127.0.0.1", 0, (err, hostname, service) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _hostname: string = hostname;
|
||||
const _service: string = service;
|
||||
});
|
||||
|
||||
dns.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "A", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "AAAA", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "ANY", (err, addresses) => {
|
||||
const _addresses: dns.AnyRecord[] = addresses;
|
||||
});
|
||||
dns.resolve("nodejs.org", "MX", (err, addresses) => {
|
||||
const _addresses: dns.MxRecord[] = addresses;
|
||||
});
|
||||
|
||||
dns.resolve4("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve4("nodejs.org", { ttl: true }, (err, addresses) => {
|
||||
const _addresses: dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
dns.resolve4("nodejs.org", { ttl }, (err, addresses) => {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
|
||||
dns.resolve6("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
dns.resolve6("nodejs.org", { ttl: true }, (err, addresses) => {
|
||||
const _addresses: dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
dns.resolve6("nodejs.org", { ttl }, (err, addresses) => {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
{
|
||||
const resolver = new dns.Resolver();
|
||||
resolver.setServers(["4.4.4.4"]);
|
||||
resolver.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* *
|
||||
* The following tests are the modules not mentioned in document but existed *
|
||||
|
||||
108
types/node/test/dns.ts
Normal file
108
types/node/test/dns.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
import { lookup, ADDRCONFIG, V4MAPPED, LookupAddress, lookupService, resolve, AnyRecord, MxRecord, resolve4, RecordWithTtl, resolve6, Resolver, ALL } from 'dns';
|
||||
|
||||
lookup("nodejs.org", (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
lookup("nodejs.org", 4, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
lookup("nodejs.org", 6, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
lookup("nodejs.org", {}, (err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
});
|
||||
lookup(
|
||||
"nodejs.org",
|
||||
{
|
||||
family: 4,
|
||||
hints: ADDRCONFIG | V4MAPPED | ALL,
|
||||
all: false
|
||||
},
|
||||
(err, address, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: string = address;
|
||||
const _family: number = family;
|
||||
}
|
||||
);
|
||||
lookup("nodejs.org", { all: true }, (err, addresses) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: LookupAddress[] = addresses;
|
||||
});
|
||||
lookup("nodejs.org", { all: true, verbatim: true }, (err, addresses) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _address: LookupAddress[] = addresses;
|
||||
});
|
||||
|
||||
function trueOrFalse(): boolean {
|
||||
return Math.random() > 0.5 ? true : false;
|
||||
}
|
||||
lookup("nodejs.org", { all: trueOrFalse() }, (err, addresses, family) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _addresses: string | LookupAddress[] = addresses;
|
||||
const _family: number | undefined = family;
|
||||
});
|
||||
|
||||
lookupService("127.0.0.1", 0, (err, hostname, service) => {
|
||||
const _err: NodeJS.ErrnoException | null = err;
|
||||
const _hostname: string = hostname;
|
||||
const _service: string = service;
|
||||
});
|
||||
|
||||
resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolve("nodejs.org", "A", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolve("nodejs.org", "AAAA", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolve("nodejs.org", "ANY", (err, addresses) => {
|
||||
const _addresses: AnyRecord[] = addresses;
|
||||
});
|
||||
resolve("nodejs.org", "MX", (err, addresses) => {
|
||||
const _addresses: MxRecord[] = addresses;
|
||||
});
|
||||
|
||||
resolve4("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolve4("nodejs.org", { ttl: true }, (err, addresses) => {
|
||||
const _addresses: RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
resolve4("nodejs.org", { ttl }, (err, addresses) => {
|
||||
const _addresses: string[] | RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
|
||||
resolve6("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolve6("nodejs.org", { ttl: true }, (err, addresses) => {
|
||||
const _addresses: RecordWithTtl[] = addresses;
|
||||
});
|
||||
{
|
||||
const ttl = false;
|
||||
resolve6("nodejs.org", { ttl }, (err, addresses) => {
|
||||
const _addresses: string[] | RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
{
|
||||
const resolver = new Resolver();
|
||||
resolver.setServers(["4.4.4.4"]);
|
||||
resolver.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolver.cancel();
|
||||
}
|
||||
@@ -70,6 +70,11 @@ import * as util from 'util';
|
||||
|
||||
{
|
||||
fs.readSync(1, new DataView(new ArrayBuffer(1)), 0, 1, 0);
|
||||
fs.readSync(1, Buffer.from(''), {
|
||||
length: 123,
|
||||
offset: 456,
|
||||
position: null,
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@@ -352,3 +357,9 @@ async function testPromisify() {
|
||||
const readStream = fs.createReadStream('./index.d.ts');
|
||||
const _rom = readStream.readableObjectMode; // $ExpectType boolean
|
||||
}
|
||||
|
||||
{
|
||||
fs.readvSync(123, [Buffer.from('wut')]);
|
||||
fs.readv(123, [Buffer.from('wut')], 123, (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => {
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { readFile } from 'fs';
|
||||
showProxy: true,
|
||||
maxArrayLength: 10,
|
||||
breakLength: 20,
|
||||
maxStringLength: 123,
|
||||
compact: true,
|
||||
sorted(a, b) {
|
||||
return b.localeCompare(a);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Readable } from "stream";
|
||||
|
||||
{
|
||||
if (workerThreads.isMainThread) {
|
||||
const { port1 } = new workerThreads.MessageChannel();
|
||||
module.exports = async function parseJSAsync(script: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new workerThreads.Worker(__filename, {
|
||||
@@ -12,7 +13,8 @@ import { Readable } from "stream";
|
||||
codeRangeSizeMb: 123,
|
||||
},
|
||||
argv: ['asd'],
|
||||
workerData: script
|
||||
workerData: script,
|
||||
transferList: [port1],
|
||||
});
|
||||
worker.on('message', resolve);
|
||||
worker.on('error', reject);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"test/cluster.ts",
|
||||
"test/crypto.ts",
|
||||
"test/dgram.ts",
|
||||
"test/dns.ts",
|
||||
"test/events.ts",
|
||||
"test/fs.ts",
|
||||
"test/global.ts",
|
||||
|
||||
12
types/node/worker_threads.d.ts
vendored
12
types/node/worker_threads.d.ts
vendored
@@ -2,6 +2,7 @@ declare module "worker_threads" {
|
||||
import { Context } from "vm";
|
||||
import { EventEmitter } from "events";
|
||||
import { Readable, Writable } from "stream";
|
||||
import { URL } from "url";
|
||||
|
||||
const isMainThread: boolean;
|
||||
const parentPort: null | MessagePort;
|
||||
@@ -70,6 +71,10 @@ declare module "worker_threads" {
|
||||
stderr?: boolean;
|
||||
execArgv?: string[];
|
||||
resourceLimits?: ResourceLimits;
|
||||
/**
|
||||
* Additional data to send in the first worker message.
|
||||
*/
|
||||
transferList?: Array<ArrayBuffer | MessagePort>;
|
||||
}
|
||||
|
||||
interface ResourceLimits {
|
||||
@@ -85,7 +90,12 @@ declare module "worker_threads" {
|
||||
readonly threadId: number;
|
||||
readonly resourceLimits?: ResourceLimits;
|
||||
|
||||
constructor(filename: string, options?: WorkerOptions);
|
||||
/**
|
||||
* @param filename The path to the Worker’s main script or module.
|
||||
* Must be either an absolute path or a relative path (i.e. relative to the current working directory) starting with ./ or ../,
|
||||
* or a WHATWG URL object using file: protocol. If options.eval is true, this is a string containing JavaScript code rather than a path.
|
||||
*/
|
||||
constructor(filename: string | URL, options?: WorkerOptions);
|
||||
|
||||
postMessage(value: any, transferList?: Array<ArrayBuffer | MessagePort>): void;
|
||||
ref(): void;
|
||||
|
||||
Reference in New Issue
Block a user