mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
refactor(node): move class-like definitions to classes (#36660)
* refactor: move class-like definitions to classes * fixup! Merge branch 'master' into chore/buffer-class
This commit is contained in:
parent
c79180dd81
commit
36ddc60d7c
2
types/node/buffer.d.ts
vendored
2
types/node/buffer.d.ts
vendored
@ -10,7 +10,7 @@ declare module "buffer" {
|
||||
|
||||
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
|
||||
|
||||
export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
|
||||
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
|
||||
|
||||
export const SlowBuffer: {
|
||||
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
|
||||
|
||||
6
types/node/child_process.d.ts
vendored
6
types/node/child_process.d.ts
vendored
@ -296,7 +296,7 @@ declare module "child_process" {
|
||||
|
||||
interface SpawnSyncOptions extends CommonOptions {
|
||||
argv0?: string; // Not specified in the docs
|
||||
input?: string | Buffer | NodeJS.TypedArray | DataView;
|
||||
input?: string | NodeJS.TypedArray | DataView;
|
||||
stdio?: StdioOptions;
|
||||
killSignal?: string | number;
|
||||
maxBuffer?: number;
|
||||
@ -328,7 +328,7 @@ declare module "child_process" {
|
||||
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
|
||||
|
||||
interface ExecSyncOptions extends CommonOptions {
|
||||
input?: string | Buffer | Uint8Array;
|
||||
input?: string | Uint8Array;
|
||||
stdio?: StdioOptions;
|
||||
shell?: string;
|
||||
killSignal?: string | number;
|
||||
@ -347,7 +347,7 @@ declare module "child_process" {
|
||||
function execSync(command: string, options?: ExecSyncOptions): Buffer;
|
||||
|
||||
interface ExecFileSyncOptions extends CommonOptions {
|
||||
input?: string | Buffer | NodeJS.TypedArray | DataView;
|
||||
input?: string | NodeJS.TypedArray | DataView;
|
||||
stdio?: StdioOptions;
|
||||
killSignal?: string | number;
|
||||
maxBuffer?: number;
|
||||
|
||||
2
types/node/crypto.d.ts
vendored
2
types/node/crypto.d.ts
vendored
@ -159,7 +159,7 @@ declare module "crypto" {
|
||||
type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
|
||||
type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
|
||||
|
||||
type Binary = Buffer | NodeJS.TypedArray | DataView;
|
||||
type Binary = NodeJS.TypedArray | DataView;
|
||||
type BinaryLike = string | Binary;
|
||||
|
||||
type CipherKey = BinaryLike | KeyObject;
|
||||
|
||||
4
types/node/dgram.d.ts
vendored
4
types/node/dgram.d.ts
vendored
@ -34,8 +34,8 @@ declare module "dgram" {
|
||||
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
||||
|
||||
class Socket extends events.EventEmitter {
|
||||
send(msg: Buffer | string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: Buffer | string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array | any[], port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
send(msg: string | Uint8Array, offset: number, length: number, port: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
||||
bind(port?: number, address?: string, callback?: () => void): void;
|
||||
bind(port?: number, callback?: () => void): void;
|
||||
bind(callback?: () => void): void;
|
||||
|
||||
10
types/node/fs.d.ts
vendored
10
types/node/fs.d.ts
vendored
@ -8,7 +8,7 @@ declare module "fs" {
|
||||
*/
|
||||
type PathLike = string | Buffer | URL;
|
||||
|
||||
type BinaryData = Buffer | DataView | NodeJS.TypedArray;
|
||||
type BinaryData = DataView | NodeJS.TypedArray;
|
||||
class Stats {
|
||||
isFile(): boolean;
|
||||
isDirectory(): boolean;
|
||||
@ -1847,7 +1847,7 @@ declare module "fs" {
|
||||
* @param length The number of bytes to read.
|
||||
* @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
|
||||
*/
|
||||
read<TBuffer extends Buffer | Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
||||
read<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
|
||||
|
||||
/**
|
||||
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
||||
@ -1899,7 +1899,7 @@ declare module "fs" {
|
||||
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
||||
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
||||
*/
|
||||
write<TBuffer extends Buffer | Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
||||
write<TBuffer extends Uint8Array>(buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<{ bytesWritten: number, buffer: TBuffer }>;
|
||||
|
||||
/**
|
||||
* Asynchronously writes `string` to the file.
|
||||
@ -1968,7 +1968,7 @@ declare module "fs" {
|
||||
* @param position The offset from the beginning of the file from which data should be read. If
|
||||
* `null`, data will be read from the current position.
|
||||
*/
|
||||
function read<TBuffer extends Buffer | Uint8Array>(
|
||||
function read<TBuffer extends Uint8Array>(
|
||||
handle: FileHandle,
|
||||
buffer: TBuffer,
|
||||
offset?: number | null,
|
||||
@ -1986,7 +1986,7 @@ declare module "fs" {
|
||||
* @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
|
||||
* @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
|
||||
*/
|
||||
function write<TBuffer extends Buffer | Uint8Array>(
|
||||
function write<TBuffer extends Uint8Array>(
|
||||
handle: FileHandle,
|
||||
buffer: TBuffer,
|
||||
offset?: number | null,
|
||||
|
||||
317
types/node/globals.d.ts
vendored
317
types/node/globals.d.ts
vendored
@ -238,15 +238,169 @@ declare var exports: any;
|
||||
|
||||
// Buffer class
|
||||
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
||||
interface Buffer extends Uint8Array {
|
||||
|
||||
interface Buffer {
|
||||
constructor: typeof Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw data is stored in instances of the Buffer class.
|
||||
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
||||
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*/
|
||||
declare class Buffer extends Uint8Array {
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||
*/
|
||||
constructor(str: string, encoding?: BufferEncoding);
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||
*/
|
||||
constructor(size: number);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
constructor(array: Uint8Array);
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
constructor(array: any[]);
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
||||
*/
|
||||
constructor(buffer: Buffer);
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
|
||||
*/
|
||||
static from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param data data to create a new Buffer
|
||||
*/
|
||||
static from(data: number[]): Buffer;
|
||||
static from(data: Uint8Array): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*/
|
||||
static from(str: string, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param values to create a new Buffer
|
||||
*/
|
||||
static of(...items: number[]): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
static isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
static isEncoding(encoding: string): encoding is BufferEncoding;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
static byteLength(
|
||||
string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer,
|
||||
encoding?: BufferEncoding
|
||||
): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
static concat(list: Uint8Array[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
static compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafeSlow(size: number): Buffer;
|
||||
/**
|
||||
* This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
|
||||
*/
|
||||
static poolSize: number;
|
||||
|
||||
write(string: string, encoding?: BufferEncoding): number;
|
||||
write(string: string, offset: number, encoding?: BufferEncoding): number;
|
||||
write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): { type: 'Buffer', data: number[] };
|
||||
toJSON(): { type: 'Buffer'; data: number[] };
|
||||
equals(otherBuffer: Uint8Array): boolean;
|
||||
compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
compare(
|
||||
otherBuffer: Uint8Array,
|
||||
targetStart?: number,
|
||||
targetEnd?: number,
|
||||
sourceStart?: number,
|
||||
sourceEnd?: number
|
||||
): number;
|
||||
copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
/**
|
||||
* Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
|
||||
@ -306,7 +460,9 @@ interface Buffer extends Uint8Array {
|
||||
writeFloatBE(value: number, offset: number): number;
|
||||
writeDoubleLE(value: number, offset: number): number;
|
||||
writeDoubleBE(value: number, offset: number): number;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
|
||||
fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
|
||||
|
||||
indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
||||
lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
@ -315,153 +471,6 @@ interface Buffer extends Uint8Array {
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw data is stored in instances of the Buffer class.
|
||||
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
||||
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*/
|
||||
declare const Buffer: {
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||
*/
|
||||
new (str: string, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||
*/
|
||||
new (size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new (array: Uint8Array): Buffer;
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
new (arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new (array: any[]): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
||||
*/
|
||||
new (buffer: Buffer): Buffer;
|
||||
prototype: Buffer;
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
|
||||
*/
|
||||
from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param data data to create a new Buffer
|
||||
*/
|
||||
from(data: number[]): Buffer;
|
||||
from(data: Uint8Array): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*/
|
||||
from(str: string, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param values to create a new Buffer
|
||||
*/
|
||||
of(...items: number[]): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
isEncoding(encoding: string): encoding is BufferEncoding;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
byteLength(
|
||||
string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer,
|
||||
encoding?: BufferEncoding
|
||||
): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
concat(list: Uint8Array[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
allocUnsafeSlow(size: number): Buffer;
|
||||
/**
|
||||
* This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
|
||||
*/
|
||||
poolSize: number;
|
||||
};
|
||||
|
||||
/*----------------------------------------------*
|
||||
* *
|
||||
* GLOBAL INTERFACES *
|
||||
@ -626,17 +635,17 @@ declare namespace NodeJS {
|
||||
isPaused(): boolean;
|
||||
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
|
||||
unpipe(destination?: WritableStream): this;
|
||||
unshift(chunk: string | Buffer | Uint8Array, encoding?: BufferEncoding): void;
|
||||
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
||||
wrap(oldStream: ReadableStream): this;
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
||||
}
|
||||
|
||||
interface WritableStream extends EventEmitter {
|
||||
writable: boolean;
|
||||
write(buffer: Buffer | Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
||||
write(str: string, encoding?: string, cb?: (err?: Error | null) => void): boolean;
|
||||
end(cb?: () => void): void;
|
||||
end(data: string | Uint8Array | Buffer, cb?: () => void): void;
|
||||
end(data: string | Uint8Array, cb?: () => void): void;
|
||||
end(str: string, encoding?: string, cb?: () => void): void;
|
||||
}
|
||||
|
||||
|
||||
10
types/node/http2.d.ts
vendored
10
types/node/http2.d.ts
vendored
@ -656,8 +656,8 @@ declare module "http2" {
|
||||
addTrailers(trailers: OutgoingHttpHeaders): void;
|
||||
readonly connection: net.Socket | tls.TLSSocket;
|
||||
end(callback?: () => void): void;
|
||||
end(data: string | Buffer | Uint8Array, callback?: () => void): void;
|
||||
end(data: string | Buffer | Uint8Array, encoding: string, callback?: () => void): void;
|
||||
end(data: string | Uint8Array, callback?: () => void): void;
|
||||
end(data: string | Uint8Array, encoding: string, callback?: () => void): void;
|
||||
readonly finished: boolean;
|
||||
getHeader(name: string): string;
|
||||
getHeaderNames(): string[];
|
||||
@ -672,8 +672,8 @@ declare module "http2" {
|
||||
statusCode: number;
|
||||
statusMessage: '';
|
||||
readonly stream: ServerHttp2Stream;
|
||||
write(chunk: string | Buffer | Uint8Array, callback?: (err: Error) => void): boolean;
|
||||
write(chunk: string | Buffer | Uint8Array, encoding: string, callback?: (err: Error) => void): boolean;
|
||||
write(chunk: string | Uint8Array, callback?: (err: Error) => void): boolean;
|
||||
write(chunk: string | Uint8Array, encoding: string, callback?: (err: Error) => void): boolean;
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this;
|
||||
writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this;
|
||||
@ -943,7 +943,7 @@ declare module "http2" {
|
||||
|
||||
export function getDefaultSettings(): Settings;
|
||||
export function getPackedSettings(settings: Settings): Buffer;
|
||||
export function getUnpackedSettings(buf: Buffer | Uint8Array): Settings;
|
||||
export function getUnpackedSettings(buf: Uint8Array): Settings;
|
||||
|
||||
export function createServer(onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
|
||||
export function createServer(options: ServerOptions, onRequestHandler?: (request: Http2ServerRequest, response: Http2ServerResponse) => void): Http2Server;
|
||||
|
||||
8
types/node/net.d.ts
vendored
8
types/node/net.d.ts
vendored
@ -38,8 +38,8 @@ declare module "net" {
|
||||
constructor(options?: SocketConstructorOpts);
|
||||
|
||||
// Extended base methods
|
||||
write(buffer: Buffer | Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||
write(str: Buffer | Uint8Array | string, encoding?: string, cb?: (err?: Error) => void): boolean;
|
||||
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
||||
write(str: Uint8Array | string, encoding?: string, cb?: (err?: Error) => void): boolean;
|
||||
|
||||
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
||||
connect(port: number, host: string, connectionListener?: () => void): this;
|
||||
@ -69,8 +69,8 @@ declare module "net" {
|
||||
|
||||
// Extended base methods
|
||||
end(cb?: () => void): void;
|
||||
end(buffer: Buffer | Uint8Array | string, cb?: () => void): void;
|
||||
end(str: Buffer | Uint8Array | string, encoding?: string, cb?: () => void): void;
|
||||
end(buffer: Uint8Array | string, cb?: () => void): void;
|
||||
end(str: Uint8Array | string, encoding?: string, cb?: () => void): void;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
|
||||
@ -6,7 +6,6 @@ import * as http from "http";
|
||||
import * as https from "https";
|
||||
import * as vm from "vm";
|
||||
import * as console2 from "console";
|
||||
import * as string_decoder from "string_decoder";
|
||||
import * as timers from "timers";
|
||||
import * as dns from "dns";
|
||||
import * as async_hooks from "async_hooks";
|
||||
@ -547,21 +546,6 @@ import Module = require("module");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// string_decoder tests : https://nodejs.org/api/string_decoder.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
const StringDecoder = string_decoder.StringDecoder;
|
||||
const buffer = new Buffer('test');
|
||||
const decoder1 = new StringDecoder();
|
||||
const decoder2 = new StringDecoder('utf8');
|
||||
const part1: string = decoder1.write(new Buffer('test'));
|
||||
const end1: string = decoder1.end();
|
||||
const part2: string = decoder2.write(new Buffer('test'));
|
||||
const end2: string = decoder1.end(new Buffer('test'));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/// Timers tests : https://nodejs.org/api/timers.html
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
6
types/node/string_decoder.d.ts
vendored
6
types/node/string_decoder.d.ts
vendored
@ -1,9 +1,7 @@
|
||||
declare module "string_decoder" {
|
||||
interface NodeStringDecoder {
|
||||
class StringDecoder {
|
||||
constructor(encoding?: string);
|
||||
write(buffer: Buffer): string;
|
||||
end(buffer?: Buffer): string;
|
||||
}
|
||||
const StringDecoder: {
|
||||
new(encoding?: string): NodeStringDecoder;
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ import { Readable, Writable } from 'stream';
|
||||
});
|
||||
}
|
||||
|
||||
const a: NodeJS.TypedArray = new Buffer(123);
|
||||
|
||||
{
|
||||
const stdin: Readable = process.stdin;
|
||||
let writableFinished: boolean;
|
||||
|
||||
9
types/node/test/string_decoder.ts
Normal file
9
types/node/test/string_decoder.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { StringDecoder } from "string_decoder";
|
||||
|
||||
const buffer = new Buffer('test');
|
||||
const decoder1 = new StringDecoder();
|
||||
const decoder2 = new StringDecoder('utf8');
|
||||
const part1: string = decoder1.write(new Buffer('test'));
|
||||
const end1: string = decoder1.end();
|
||||
const part2: string = decoder2.write(new Buffer('test'));
|
||||
const end2: string = decoder1.end(new Buffer('test'));
|
||||
4
types/node/tls.d.ts
vendored
4
types/node/tls.d.ts
vendored
@ -245,7 +245,7 @@ declare module "tls" {
|
||||
* An array of strings or a Buffer naming possible ALPN protocols.
|
||||
* (Protocols should be ordered by their priority.)
|
||||
*/
|
||||
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
|
||||
ALPNProtocols?: string[] | Uint8Array[] | Uint8Array;
|
||||
/**
|
||||
* SNICallback(servername, cb) <Function> A function that will be
|
||||
* called if the client supports SNI TLS extension. Two arguments
|
||||
@ -262,7 +262,7 @@ declare module "tls" {
|
||||
* effect if requestCert is true.
|
||||
* @default true
|
||||
*/
|
||||
rejectUnauthorized?: boolean; // Defaults to true
|
||||
rejectUnauthorized?: boolean;
|
||||
}
|
||||
|
||||
interface TlsOptions extends SecureContextOptions, CommonConnectionOptions {
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
"test/readline.ts",
|
||||
"test/repl.ts",
|
||||
"test/stream.ts",
|
||||
"test/string_decoder.ts",
|
||||
"test/tls.ts",
|
||||
"test/tty.ts",
|
||||
"test/util.ts",
|
||||
|
||||
4
types/node/zlib.d.ts
vendored
4
types/node/zlib.d.ts
vendored
@ -18,7 +18,7 @@ declare module "zlib" {
|
||||
level?: number; // compression only
|
||||
memLevel?: number; // compression only
|
||||
strategy?: number; // compression only
|
||||
dictionary?: Buffer | NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
|
||||
dictionary?: NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
|
||||
}
|
||||
|
||||
interface BrotliOptions {
|
||||
@ -79,7 +79,7 @@ declare module "zlib" {
|
||||
function createInflateRaw(options?: ZlibOptions): InflateRaw;
|
||||
function createUnzip(options?: ZlibOptions): Unzip;
|
||||
|
||||
type InputType = string | Buffer | DataView | ArrayBuffer | NodeJS.TypedArray;
|
||||
type InputType = string | DataView | ArrayBuffer | NodeJS.TypedArray;
|
||||
|
||||
type CompressCallback = (error: Error | null, result: Buffer) => void;
|
||||
|
||||
|
||||
4
types/readable-stream/index.d.ts
vendored
4
types/readable-stream/index.d.ts
vendored
@ -9,7 +9,7 @@
|
||||
import * as events from "events";
|
||||
import * as stream from "stream";
|
||||
import * as SafeBuffer from "safe-buffer";
|
||||
import { NodeStringDecoder } from "string_decoder";
|
||||
import { StringDecoder } from "string_decoder";
|
||||
|
||||
declare class _Readable extends stream.Readable {
|
||||
// static ReadableState: _Readable.ReadableState;
|
||||
@ -134,7 +134,7 @@ declare namespace _Readable {
|
||||
awaitDrain: number;
|
||||
defaultEncoding: string;
|
||||
readingMore: boolean;
|
||||
decoder: NodeStringDecoder | null;
|
||||
decoder: StringDecoder | null;
|
||||
encoding: string | null;
|
||||
|
||||
// new (options: ReadableStateOptions, stream: _Readable): ReadableState;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user