diff --git a/mz/child_process.d.ts b/mz/child_process.d.ts new file mode 100644 index 0000000000..e7e89ede88 --- /dev/null +++ b/mz/child_process.d.ts @@ -0,0 +1,28 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as child_process from "child_process"; +export * from "child_process"; + +export function exec(command: string, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function exec(command: string, options: child_process.ExecOptionsWithBufferEncoding, callback: (error: Error, stdout: Buffer, stderr: Buffer) => void): child_process.ChildProcess; +export function exec(command: string, options: child_process.ExecOptionsWithStringEncoding | child_process.ExecOptions | undefined | null, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function exec(command: string, options: child_process.ExecOptionsWithBufferEncoding): Promise<[Buffer, Buffer]>; +export function exec(command: string, options?: child_process.ExecFileOptionsWithStringEncoding | child_process.ExecOptions | null): Promise<[Buffer, Buffer]>; + +export function execFile(file: string, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function execFile(file: string, args: string[] | null | undefined, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function execFile(file: string, args: string[] | null | undefined, options: child_process.ExecFileOptionsWithBufferEncoding, callback: (error: Error, stdout: Buffer, stderr: Buffer) => void): child_process.ChildProcess; +export function execFile(file: string, args: string[] | null | undefined, options: child_process.ExecFileOptionsWithStringEncoding | child_process.ExecFileOptions | undefined | null, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function execFile(file: string, args: string[] | null | undefined, options: child_process.ExecFileOptionsWithBufferEncoding): Promise<[Buffer, Buffer]>; +export function execFile(file: string, args: string[] | null | undefined, options?: child_process.ExecFileOptionsWithStringEncoding | child_process.ExecFileOptions | null): Promise<[string, string]>; +export function execFile(file: string, options: child_process.ExecFileOptionsWithBufferEncoding, callback: (error: Error, stdout: Buffer, stderr: Buffer) => void): child_process.ChildProcess; +export function execFile(file: string, options: child_process.ExecFileOptionsWithStringEncoding | child_process.ExecFileOptions | undefined | null, callback: (error: Error, stdout: string, stderr: string) => void): child_process.ChildProcess; +export function execFile(file: string, options: child_process.ExecFileOptionsWithBufferEncoding): Promise<[Buffer, Buffer]>; +export function execFile(file: string, options?: child_process.ExecFileOptionsWithStringEncoding | child_process.ExecFileOptions | null): Promise<[string, string]>; \ No newline at end of file diff --git a/mz/crypto.d.ts b/mz/crypto.d.ts new file mode 100644 index 0000000000..2ee0c8b743 --- /dev/null +++ b/mz/crypto.d.ts @@ -0,0 +1,20 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman , Ron Buckton +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as crypto from "crypto"; +export * from "crypto"; + +export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; +export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest?: string): Promise; + +export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; +export function randomBytes(size: number): Promise; + +export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; +export function pseudoRandomBytes(size: number): Promise; \ No newline at end of file diff --git a/mz/dns.d.ts b/mz/dns.d.ts new file mode 100644 index 0000000000..27b4b7c4b6 --- /dev/null +++ b/mz/dns.d.ts @@ -0,0 +1,43 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman , Ron Buckton +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as dns from "dns"; +export * from "dns"; + +export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): void; +export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): void; +export function lookup(domain: string, family?: number): Promise<[string, number]>; + +export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolve(domain: string, rrtype?: string): Promise; + +export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolve4(domain: string): Promise; + +export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolve6(domain: string): Promise; + +export function resolveMx(domain: string, callback: (err: Error, addresses: dns.MxRecord[]) => void): void; +export function resolveMx(domain: string): Promise; + +export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolveTxt(domain: string): Promise; + +export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolveSrv(domain: string): Promise; + +export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolveNs(domain: string): Promise; + +export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): void; +export function resolveCname(domain: string): Promise; + +export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): void; +export function reverse(ip: string): Promise; \ No newline at end of file diff --git a/mz/fs.d.ts b/mz/fs.d.ts new file mode 100644 index 0000000000..975850c3ab --- /dev/null +++ b/mz/fs.d.ts @@ -0,0 +1,505 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman , Ron Buckton +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as fs from "fs"; +export * from "fs"; + +/** + * Asynchronous `rename(2)`. + */ +export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `rename(2)`. + */ +export function rename(oldPath: string, newPath: string): Promise; + +/** + * Asynchronous `truncate(2)`. + * + * If the file was larger than `len` bytes, only the first `len` bytes will be retained in the file. + */ +export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `truncate(2)`. + * + * If the file was larger than `len` bytes, only the first `len` bytes will be retained in the file. + */ +export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `truncate(2)`. + * + * If the file was larger than `len` bytes, only the first `len` bytes will be retained in the file. + */ +export function truncate(path: string | Buffer, len?: number): Promise; + +/** + * Asynchronous `ftruncate(2)`. + * + * If the file referred to by the file descriptor was larger than `len` bytes, only the first `len` + * bytes will be retained in the file. + */ +export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `ftruncate(2)`. + */ +export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `ftruncate(2)`. + * + * If the file referred to by the file descriptor was larger than `len` bytes, only the first `len` + * bytes will be retained in the file. + */ +export function ftruncate(fd: number, len?: number): Promise; + +/** + * Asynchronous `chown(2)`. + */ +export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `chown(2)`. + */ +export function chown(path: string | Buffer, uid: number, gid: number): Promise; + +/** + * Asynchronous `fchown(2)`. + */ +export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `fchown(2)`. + */ +export function fchown(fd: number, uid: number, gid: number): Promise; + +/** + * (Deprecated) Asynchronous `lchown(2)`. + */ +export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * (Deprecated) Asynchronous `lchown(2)`. + */ +export function lchown(path: string | Buffer, uid: number, gid: number): Promise; + +/** + * Asynchronous `chmod(2)`. + */ +export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `chmod(2)`. + */ +export function chmod(path: string | Buffer, mode: string | number): Promise; + +/** + * Asynchronous `fchmod(2)`. + */ +export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `fchmod(2)`. + */ +export function fchmod(fd: number, mode: string | number): Promise; + +/** + * (Deprecated) Asynchronous `lchmod(2)`. + * + * NOTE: Only available on Mac OS X. + */ +export function lchmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * (Deprecated) Asynchronous `lchmod(2)`. + * + * NOTE: Only available on Mac OS X. + */ +export function lchmod(path: string | Buffer, mode: string | number): Promise; + +/** + * Asynchronous `stat(2)`. + */ +export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => any): void; + +/** + * Asynchronous `stat(2)`. + */ +export function stat(path: string | Buffer): Promise; + +/** + * Asynchronous `lstat(2)`. + * + * `lstat()` is identical to `stat()`, except that if path is a symbolic link, then the link itself + * is stat-ed, not the file that it refers to. + */ +export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: fs.Stats) => any): void; + +/** + * Asynchronous `lstat(2)`. + * + * `lstat()` is identical to `stat()`, except that if path is a symbolic link, then the link itself + * is stat-ed, not the file that it refers to. + */ +export function lstat(path: string | Buffer): Promise; + +/** + * Asynchronous `fstat(2)`. + */ +export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: fs.Stats) => any): void; + +/** + * Asynchronous `fstat(2)`. + */ +export function fstat(fd: number): Promise; + +/** + * Asynchronous `link(2)`. + */ +export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `link(2)`. + */ +export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise; + +/** + * Asynchronous `symlink(2)`. + */ +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `symlink(2)`. + */ +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `symlink(2)`. + */ +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise; + +/** + * Asynchronous `readlink(2)`. + */ +export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void; + +/** + * Asynchronous `readlink(2)`. + */ +export function readlink(path: string | Buffer): Promise; + +/** + * Asynchronous `realpath(3)`. + */ +export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + +/** + * Asynchronous `realpath(3)`. + */ +export function realpath(path: string | Buffer): Promise; + +/** + * Asynchronous `unlink(2)`. + * + * Deletes the file specified in `path`. + * + * @param path The path to a file. + */ +export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `unlink(2)`. + * + * Deletes the file specified in `path`. + * + * @param path The path to a file. + */ +export function unlink(path: string | Buffer): Promise; + +/** + * Asynchronous `rmdir(2)` + * + * Removes the directory specified in `path`. + * + * @param path The path to the directory. + */ +export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `rmdir(2)` + * + * Removes the directory specified in `path`. + * + * @param path The path to the directory. + */ +export function rmdir(path: string | Buffer): Promise; + +/** + * Asynchronous `mkdir(2)`. + * + * Creates the directory specified in `path`. + * + * @param path The path to the directory. + * @param mode The mode for the directory (default: `0777`). + */ +export function mkdir(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `mkdir(2)`. + * + * Creates the directory specified in `path`. + * + * @param path The path to the directory. + * @param mode The mode for the directory (default: `0777`). + */ +export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `mkdir(2)`. + * + * Creates the directory specified in `path`. + * + * @param path The path to the directory. + * @param mode The mode for the directory (default: `0777`). + */ +export function mkdir(path: string | Buffer, mode?: string | number): Promise; + +/** + * Asynchronous `readdir(3)`. + * + * Reads the contents of a directory. + */ +export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void; + +/** + * Asynchronous `readdir(3)`. + * + * Reads the contents of a directory. + */ +export function readdir(path: string | Buffer): Promise; + +/** + * Asynchronous `close(2)`. + */ +export function close(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `close(2)`. + */ +export function close(fd: number): Promise; + +/** + * Asynchronous `open(2)`. + */ +export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; + +/** + * Asynchronous `open(2)`. + */ +export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; + +/** + * Asynchronous `open(2)`. + */ +export function open(path: string | Buffer, flags: string | number, mode?: number): Promise; + +/** + * Change the file timestamps of the file referenced by the supplied path. + */ +export function utimes(path: string | Buffer, atime: number | Date, mtime: number | Date, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Change the file timestamps of the file referenced by the supplied path. + */ +export function utimes(path: string | Buffer, atime: number | Date, mtime: number | Date): Promise; + +/** + * Change the file timestamps of a file referenced by the supplied file descriptor. + */ +export function futimes(fd: number, atime: number | Date, mtime: number | Date, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Change the file timestamps of a file referenced by the supplied file descriptor. + */ +export function futimes(fd: number, atime: number | Date, mtime: number | Date): Promise; + +/** + * Asynchronous `fsync(2)`. + */ +export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronous `fsync(2)`. + */ +export function fsync(fd: number): Promise; + +/** + * Write `data` to the file specified by `fd`. + */ +export function write(fd: number, data: any, position: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + +/** + * Write `data` to the file specified by `fd`. + */ +export function write(fd: number, data: any, position: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + +/** + * Write `data` to the file specified by `fd`. + */ +export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + +/** + * Write `data` to the file specified by `fd`. + */ +export function write(fd: number, data: string, position?: number, encoding?: string): Promise<[number, string]>; + +/** + * Write `buffer` to the file specified by `fd`. + */ +export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + +/** + * Write `buffer` to the file specified by `fd`. + */ +export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + +/** + * Write `buffer` to the file specified by `fd`. + */ +export function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number): Promise<[number, Buffer]>; + +/** + * Read data from the file specified by `fd`. + */ +export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + +/** + * Read data from the file specified by `fd`. + */ +export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number): Promise<[number, Buffer]>; + +/** + * Asynchronously reads the entire contents of a file. + * + * @param file The filename or descriptor + * @param options The encoding for the result, or an object containing options. + */ +export function readFile(file: string | number | Buffer, options: { encoding?: "buffer" | null; flag?: string; } | "buffer" | undefined | null, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + +/** + * Asynchronously reads the entire contents of a file. + * + * @param file The filename or descriptor + * @param options The encoding for the result, or an object containing options. + */ +export function readFile(file: string | number | Buffer, options: { encoding: string; flag?: string; } | string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + +/** + * Asynchronously reads the entire contents of a file. + * + * @param file The filename or descriptor + */ +export function readFile(file: string | number | Buffer, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + +/** + * Asynchronously reads the entire contents of a file. + * + * @param file The filename or descriptor + * @param options The encoding for the result, or an object containing options. + */ +export function readFile(file: string | number | Buffer, options?: { encoding?: "buffer" | null; flag?: string; } | "buffer" | null): Promise; + +/** + * Asynchronously reads the entire contents of a file. + * + * @param file The filename or descriptor + * @param options The encoding for the result, or an object containing options. + */ +export function readFile(file: string | number | Buffer, options: { encoding: string; flag?: string; } | string): Promise; + +/** + * Asynchronously writes data to a file, replacing the file if it already exists. + */ +export function writeFile(filename: string | number | Buffer, data: string | Buffer, options: { encoding?: string | null; mode?: string | number; flag?: string; } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronously writes data to a file, replacing the file if it already exists. + */ +export function writeFile(filename: string | number | Buffer, data: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronously writes data to a file, replacing the file if it already exists. + */ +export function writeFile(file: string | number | Buffer, data: string | Buffer, options?: { encoding?: string | null; mode?: string | number; flag?: string; } | string | null): Promise; + +/** + * Asynchronously append data to a file, creating the file if it does not yet exist. + * + * @param file The path to the file or a file descriptor. + * @param data The data to append to the file. + * @param options The encoding for `data`, or an object with additional options. + */ +export function appendFile(file: string | number | Buffer, data: string | Buffer, options: { encoding?: string | null; mode?: string | number; flag?: string; } | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronously append data to a file, creating the file if it does not yet exist. + * + * @param file The path to the file or a file descriptor. + * @param data The data to append to the file. + */ +export function appendFile(file: string | number | Buffer, data: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Asynchronously append data to a file, creating the file if it does not yet exist. + * + * @param file The path to the file or a file descriptor. + * @param data The data to append to the file. + * @param options The encoding for `data`, or an object with additional options. + */ +export function appendFile(file: string | number | Buffer, data: string | Buffer, options?: { encoding?: string | null; mode?: number | string; flag?: string; } | string | null): Promise; + +/** + * Test whether or not the given path exists by checking with the file system. + * + * @param path The path to access. + */ +export function exists(path: string | Buffer, callback: (err: NodeJS.ErrnoException, exists: boolean) => void): void; + +/** + * Test whether or not the given path exists by checking with the file system. + * + * @param path The path to access. + */ +export function exists(path: string): Promise; + +/** + * Tests a user's permissions for the file specified by `path`. + * + * @param path The path to access. + * @param mode An optional integer that specifies the accessibility checks to be performed. + */ +export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Tests a user's permissions for the file specified by `path`. + * + * @param path The path to access. + */ +export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; + +/** + * Tests a user's permissions for the file specified by `path`. + * + * @param path The path to access. + * @param mode An optional integer that specifies the accessibility checks to be performed. + */ +export function access(path: string, mode?: number): Promise; \ No newline at end of file diff --git a/mz/index.d.ts b/mz/index.d.ts index 5752207da0..ee3008389d 100644 --- a/mz/index.d.ts +++ b/mz/index.d.ts @@ -5,793 +5,12 @@ // Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts -/// /// -declare module "mz/fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - } - - export interface ReadStream extends stream.Readable { - close(): void; - } - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - } - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string): Promise; - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rename - * @param oldPath - * @param newPath - */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number): Promise; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number): Promise; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number): Promise; - export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number): Promise; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number): Promise; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number): Promise; - export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string, mode: string): Promise; - export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string, mode: number): void; - export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number): Promise; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string): Promise; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string, mode: number): void; - export function lchmodSync(path: string, mode: string): void; - export function stat(path: string): Promise; - export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string): Promise; - export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number): Promise; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string): Stats; - export function lstatSync(path: string): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string): Promise; - export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string): Promise; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string): Promise; - export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string): string; - export function realpath(path: string): Promise; - export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}): Promise; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; - export function realpathSync(path: string, cache?: { [path: string]: string }): string; - /* - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string): Promise; - /* - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string): void; - /* - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string): Promise; - /* - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string): Promise; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: number): Promise; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: string): Promise; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: number): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string): Promise; - export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string): string[]; - export function close(fd: number): Promise; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string, flags: string): Promise; - export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number): Promise; - export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string): Promise; - export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function openSync(path: string, flags: string, mode?: number): number; - export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number): Promise; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string, atime: Date, mtime: Date): Promise; - export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string, atime: number, mtime: number): void; - export function utimesSync(path: string, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number): Promise; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date): Promise; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number): Promise; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number): Promise<[number, Buffer]>; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number): Promise<[number, Buffer]>; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any): Promise<[number, string]>; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number): Promise<[number, string]>; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string): Promise<[number, string]>; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number): Promise<[number, Buffer]>; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string): Promise; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }): Promise; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }): Promise; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string): Promise; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any): Promise; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }): Promise; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }): Promise; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }): Promise; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }): Promise; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any): Promise; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; - export function exists(path: string): Promise; - export function exists(path: string, callback: (err:any, exists: boolean) => void): void; - export function existsSync(path: string): boolean; - /** Constant for fs.access(). File is visible to the calling process. */ - export var F_OK: number; - /** Constant for fs.access(). File can be read by the calling process. */ - export var R_OK: number; - /** Constant for fs.access(). File can be written by the calling process. */ - export var W_OK: number; - /** Constant for fs.access(). File can be executed by the calling process. */ - export var X_OK: number; - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string): Promise; - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string, mode: number): Promise; - export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string, mode ?: number): void; - export function createReadStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - }): ReadStream; - export function createWriteStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - }): WriteStream; -} - -declare module "mz/dns" { - export function lookup(domain: string, family: number): Promise<[string, number]>; - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; - export function lookup(domain: string): Promise<[string, number]>; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; - export function resolve(domain: string, rrtype: string): Promise; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve(domain: string): Promise; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve4(domain: string): Promise; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve6(domain: string): Promise; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveMx(domain: string): Promise; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveTxt(domain: string): Promise; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveSrv(domain: string): Promise; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveNs(domain: string): Promise; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveCname(domain: string): Promise; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function reverse(ip: string): Promise; - export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; -} - -declare module "mz/crypto" { - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: any; //string | string array - crl: any; //string | string array - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string): Hmac; - export function createHmac(algorithm: string, key: Buffer): Hmac; - export interface Hash { - update(data: any, input_encoding?: string): Hash; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: any, input_encoding?: string): Hmac; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - export interface Cipher { - update(data: Buffer): Buffer; - update(data: string, input_encoding?: string, output_encoding?: string): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - export interface Decipher { - update(data: Buffer): Buffer; - update(data: string, input_encoding?: string, output_encoding?: string): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: any): void; - sign(private_key: string, output_format: string): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: any): void; - verify(object: string, signature: string, signature_format?: string): boolean; - } - export function createDiffieHellman(prime_length: number): DiffieHellman; - export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; - export interface DiffieHellman { - generateKeys(encoding?: string): string; - computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; - getPrime(encoding?: string): string; - getGenerator(encoding: string): string; - getPublicKey(encoding?: string): string; - getPrivateKey(encoding?: string): string; - setPublicKey(public_key: string, encoding?: string): void; - setPrivateKey(public_key: string, encoding?: string): void; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number): Promise; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string): Promise; - export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; - export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer; - //export function randomBytes(size: number): Buffer; - export function randomBytes(size: number): Promise; - //export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; - //export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number): Promise; - //export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; - export interface RsaPublicKey { - key: string; - padding?: any; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: any; - } - export function publicEncrypt(public_key: string|RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string|RsaPrivateKey, buffer: Buffer): Buffer -} - -declare module "mz/child_process" { - import * as events from "events"; - import * as stream from "stream"; - - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: (stream.Readable|stream.Writable)[]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): void; - disconnect(): void; - unref(): void; - } - - export function spawn(command: string, args?: string[], options?: { - cwd?: string; - stdio?: any; - custom?: any; - env?: any; - detached?: boolean; - }): ChildProcess; - export function exec(command: string, options: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }): Promise<[Buffer, Buffer]>; - export function exec(command: string, options: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function exec(command: string): Promise<[Buffer, Buffer]>; - export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string): Promise<[Buffer, Buffer]>; - export function execFile(file: string, - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[]): Promise<[Buffer, Buffer]>; - export function execFile(file: string, args?: string[], - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], options?: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }): Promise<[Buffer, Buffer]>; - export function execFile(file: string, args?: string[], options?: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function fork(modulePath: string, args?: string[], options?: { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - }): ChildProcess; - export function spawnSync(command: string, args?: string[], options?: { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): { - pid: number; - output: string[]; - stdout: string | Buffer; - stderr: string | Buffer; - status: number; - signal: string; - error: Error; - }; - export function execSync(command: string, options?: { - cwd?: string; - input?: string|Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): string | Buffer; - export function execFileSync(command: string, args?: string[], options?: { - cwd?: string; - input?: string|Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): string | Buffer; -} - - -declare module "mz/zlib" { - import * as stream from "stream"; - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } - - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; - - export function deflate(buf: Buffer): Promise; - - export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateSync(buf: Buffer, options?: ZlibOptions): any; - export function deflateRaw(buf: Buffer): Promise; - export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function gzip(buf: Buffer): Promise; - export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): any; - export function gunzip(buf: Buffer): Promise; - export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; - export function inflate(buf: Buffer): Promise; - export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): any; - export function inflateRaw(buf: Buffer): Promise; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function unzip(buf: Buffer): Promise; - export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): any; - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; - export var Z_NULL: number; -} - -declare module "mz/readline" { - import * as events from "events"; - import * as stream from "stream"; - - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - question(query: string): Promise; - pause(): ReadLine; - resume(): ReadLine; - close(): void; - write(data: string|Buffer, key?: Key): void; - } - - export interface Completer { - (line: string): Promise<[string[], string]>; - (line: string): [string[], string]; - (line: string, callback: (err: any, result: [string[], string]) => void): any; - (line: string, callback: (err: any, result: CompleterResult) => void): any; - } - - export interface CompleterResult { - completions: string[]; - line: string; - } - - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer; - terminal?: boolean; - historySize?: number; - } - - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; - export function createInterface(options: ReadLineOptions): ReadLine; - - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; -} - - -declare module "mz"{ - export import child_process = require("mz/child_process"); - export import crypto = require("mz/child_process") - export import dns = require("mz/dns") - export import fs = require("mz/fs") - export import readline = require("mz/readline") - export import zlib = require("mz/zlib") -} +import * as child_process from "mz/child_process"; +import * as crypto from "mz/crypto"; +import * as dns from "mz/dns"; +import * as fs from "mz/fs"; +import * as readline from "mz/readline"; +import * as zlib from "mz/zlib"; +export { child_process, crypto, dns, fs, readline, zlib }; \ No newline at end of file diff --git a/mz/mz-tests.ts b/mz/mz-tests.ts index f0b4222201..8246eecbab 100644 --- a/mz/mz-tests.ts +++ b/mz/mz-tests.ts @@ -6,7 +6,6 @@ import assert = require('assert') import fs = require('mz/fs') - describe('fs', function () { it('.stat()', function (done) { @@ -72,7 +71,7 @@ describe('child_process', function () { describe('callback support', function () { it('.exec() success', function (done) { cp.exec('node --version', function (err, stdout) { - assert.equal(stdout.toString('utf8')[0], 'v') + assert.equal(stdout.toString()[0], 'v') done() }) }) @@ -86,7 +85,7 @@ describe('child_process', function () { }) }) -import crypto = require('mz/crypto') +import * as crypto from "mz/crypto"; describe('crypto', function () { diff --git a/mz/readline.d.ts b/mz/readline.d.ts new file mode 100644 index 0000000000..103c8520e6 --- /dev/null +++ b/mz/readline.d.ts @@ -0,0 +1,32 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as readline from "readline"; +export * from "readline"; + +export interface ReadLine extends readline.ReadLine { + question(query: string, callback: (answer: string) => void): void; + question(query: string): Promise; +} + +export interface Completer { + (line: string, callback: (err: any, result: [string[], string]) => void): void; + (line: string): Promise<[string[], string]> | [string[], string]; +} + +export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + completer?: Completer; + terminal?: boolean; + historySize?: number; +} + +export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; +export function createInterface(options: ReadLineOptions): ReadLine; \ No newline at end of file diff --git a/mz/tsconfig.json b/mz/tsconfig.json index f5c6c7a22b..83fafa87ea 100644 --- a/mz/tsconfig.json +++ b/mz/tsconfig.json @@ -9,10 +9,15 @@ "../" ], "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true + "noEmit": true }, "files": [ + "fs.d.ts", + "dns.d.ts", + "crypto.d.ts", + "child_process.d.ts", + "zlib.d.ts", + "readline.d.ts", "index.d.ts", "mz-tests.ts" ] diff --git a/mz/zlib.d.ts b/mz/zlib.d.ts new file mode 100644 index 0000000000..95ace21eaa --- /dev/null +++ b/mz/zlib.d.ts @@ -0,0 +1,32 @@ +// Type definitions for mz +// Project: https://github.com/normalize/mz +// Definitions by: Thomas Hickman +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Modified from the node.js definitions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts + +/// + +import * as zlib from "zlib"; +export * from "zlib"; + +export function deflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function deflate(buf: Buffer): Promise; + +export function deflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function deflateRaw(buf: Buffer): Promise; + +export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function gzip(buf: Buffer): Promise; + +export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function gunzip(buf: Buffer): Promise; + +export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function inflate(buf: Buffer): Promise; + +export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function inflateRaw(buf: Buffer): Promise; + +export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; +export function unzip(buf: Buffer): Promise; \ No newline at end of file