diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index e789c5627f..b17cb07e32 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -1,48 +1,48 @@ import fs = require('fs-extra-promise-es6'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: string; -var offset: number; -var length: number; -var position: number; -var cacheBool: boolean; -var cacheStr: string; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.OpenOptions; -var watcher: fs.FSWatcher; -var readStreeam: stream.Readable; -var writeStream: stream.Writable; -var isDirectory: boolean; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: any; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: string; +let offset: number; +let length: number; +let position: number; +let cacheBool: boolean; +let cacheStr: string; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.OpenOptions; +let watcher: fs.FSWatcher; +let readStreeam: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -120,13 +120,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cacheBool); fs.unlink(path, errorCallback); @@ -138,13 +135,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeStr, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeStr); fs.utimes(path, atime, mtime, errorCallback); @@ -154,24 +149,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: Error, data: string) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -204,10 +193,8 @@ fs.watchFile(filename, { }); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -224,10 +211,9 @@ writeStream = fs.createWriteStream(path, { encoding: str }); -var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { }; fs.isDirectory(path, isDirectoryCallback); fs.isDirectory(path); isDirectory = fs.isDirectorySync(path); fs.isDirectoryAsync(path); - diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 82ab2da35b..db262c1460 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -1,158 +1,194 @@ -// Type definitions for fs-extra-promise-es6 +// Type definitions for fs-extra-promise-es6 0.1 // Project: https://github.com/vinsonchuong/fs-extra-promise-es6 -// Definitions by: midknight41 , Jason Swearingen , Joshua DeVinney , Hiromi Shikata +// Definitions by: midknight41 +// Jason Swearingen +// Joshua DeVinney +// Hiromi Shikata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: fs-extra-promise typings (minus Bluebird) -/// - +/// import stream = require("stream"); import fs = require("fs"); -export type Stats = fs.Stats +export type Stats = fs.Stats; export interface FSWatcher { close(): void; } -export declare class ReadStream extends stream.Readable { } -export declare class WriteStream extends stream.Writable { } +export class ReadStream extends stream.Readable { } +export class WriteStream extends stream.Writable { } -//extended methods -export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void; -export declare function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; +// extended methods +export function copy(src: string, dest: string, callback?: (err: Error) => void): void; +export function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; -export declare function copySync(src: string, dest: string): void; -export declare function copySync(src: string, dest: string, filter: (src: string) => boolean): void; +export function copySync(src: string, dest: string, filter?: (src: string) => boolean): void; -export declare function createFile(file: string, callback?: (err: Error) => void): void; -export declare function createFileSync(file: string): void; +export function createFile(file: string, callback?: (err: Error) => void): void; +export function createFileSync(file: string): void; -export declare function mkdirs(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirp(dir: string, callback?: (err: Error) => void): void; -export declare function mkdirsSync(dir: string): void; -export declare function mkdirpSync(dir: string): void; +export function mkdirs(dir: string, callback?: (err: Error) => void): void; +export function mkdirp(dir: string, callback?: (err: Error) => void): void; +export function mkdirsSync(dir: string): void; +export function mkdirpSync(dir: string): void; -export declare function outputFile(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputFileSync(file: string, data: any): void; +export function outputFile(file: string, data: any, callback?: (err: Error) => void): void; +export function outputFileSync(file: string, data: any): void; -export declare function outputJson(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; -export declare function outputJsonSync(file: string, data: any): void; -export declare function outputJSONSync(file: string, data: any): void; +export function outputJson(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; +export function outputJsonSync(file: string, data: any): void; +export function outputJSONSync(file: string, data: any): void; -export declare function readJson(file: string, callback?: (err: Error) => void): void; -export declare function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, callback?: (err: Error) => void): void; -export declare function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJson(file: string, callback?: (err: Error) => void): void; +export function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; +export function readJSON(file: string, callback?: (err: Error) => void): void; +export function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function readJsonSync(file: string, options?: OpenOptions): void; -export declare function readJSONSync(file: string, options?: OpenOptions): void; +export function readJsonSync(file: string, options?: OpenOptions): void; +export function readJSONSync(file: string, options?: OpenOptions): void; -export declare function remove(dir: string, callback?: (err: Error) => void): void; -export declare function removeSync(dir: string): void; +export function remove(dir: string, callback?: (err: Error) => void): void; +export function removeSync(dir: string): void; // export function delete(dir: string, callback?: (err: Error) => void): void; // export function deleteSync(dir: string): void; -export declare function writeJson(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; -export declare function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; +export function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeJsonSync(file: string, object: any, options?: OpenOptions): void; -export declare function writeJSONSync(file: string, object: any, options?: OpenOptions): void; +export function writeJsonSync(file: string, object: any, options?: OpenOptions): void; +export function writeJSONSync(file: string, object: any, options?: OpenOptions): void; -export declare function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; -export declare function renameSync(oldPath: string, newPath: string): void; -export declare function truncate(fd: number, len: number, callback?: (err: Error) => void): void; -export declare function truncateSync(fd: number, len: number): void; -export declare function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function chownSync(path: string, uid: number, gid: number): void; -export declare function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function fchownSync(fd: number, uid: number, gid: number): void; -export declare function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; -export declare function lchownSync(path: string, uid: number, gid: number): void; -export declare function chmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function chmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function chmodSync(path: string, mode: number): void; -export declare function chmodSync(path: string, mode: string): void; -export declare function fchmod(fd: number, mode: number, callback?: (err: Error) => void): void; -export declare function fchmod(fd: number, mode: string, callback?: (err: Error) => void): void; -export declare function fchmodSync(fd: number, mode: number): void; -export declare function fchmodSync(fd: number, mode: string): void; -export declare function lchmod(path: string, mode: string, callback?: (err: Error) => void): void; -export declare function lchmod(path: string, mode: number, callback?: (err: Error) => void): void; -export declare function lchmodSync(path: string, mode: number): void; -export declare function lchmodSync(path: string, mode: string): void; -export declare function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; -export declare function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; -export declare function statSync(path: string): Stats; -export declare function lstatSync(path: string): Stats; -export declare function fstatSync(fd: number): Stats; -export declare function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; -export declare function linkSync(srcpath: string, dstpath: string): void; -export declare function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; -export declare function symlinkSync(srcpath: string, dstpath: string, type?: string): void; -export declare function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; -export declare function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; -export declare function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; -export declare function realpathSync(path: string, cache?: boolean): string; -export declare function unlink(path: string, callback?: (err: Error) => void): void; -export declare function unlinkSync(path: string): void; -export declare function rmdir(path: string, callback?: (err: Error) => void): void; -export declare function rmdirSync(path: string): void; -export declare function mkdir(path: string, mode?: number, callback?: (err: Error) => void): void; -export declare function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void; -export declare function mkdirSync(path: string, mode?: number): void; -export declare function mkdirSync(path: string, mode?: string): void; -export declare function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; -export declare function readdirSync(path: string): string[]; -export declare function close(fd: number, callback?: (err: Error) => void): void; -export declare function closeSync(fd: number): void; -export declare function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; -export declare function openSync(path: string, flags: string, mode?: string): number; -export declare function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function utimesSync(path: string, atime: number, mtime: number): void; -export declare function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; -export declare function futimesSync(fd: number, atime: number, mtime: number): void; -export declare function fsync(fd: number, callback?: (err: Error) => void): void; -export declare function fsyncSync(fd: number): void; -export declare function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; -export declare function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; -export declare function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; -export declare function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, options: OpenOptions, callback: (err: Error, data: string) => void): void; -export declare function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; -export declare function readFileSync(filename: string): NodeBuffer; -export declare function readFileSync(filename: string, encoding: string): string; -export declare function readFileSync(filename: string, options: OpenOptions): string; -export declare function writeFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function writeFile(filename: string, data: any, options?: OpenOptions, callback?: (err: Error) => void): void; -export declare function writeFileSync(filename: string, data: any, encoding?: string): void; -export declare function writeFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function appendFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; -export declare function appendFile(filename: string, data: any, option?: OpenOptions, callback?: (err: Error) => void): void; -export declare function appendFileSync(filename: string, data: any, encoding?: string): void; -export declare function appendFileSync(filename: string, data: any, option?: OpenOptions): void; -export declare function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; -export declare function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; -export declare function unwatchFile(filename: string, listener?: Stats): void; -export declare function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; -export declare function exists(path: string, callback?: (exists: boolean) => void): void; -export declare function existsSync(path: string): boolean; -export declare function ensureDir(path: string, cb: (err: Error) => void): void; -export declare function ensureDirSync(path: string): void; +export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; +export function renameSync(oldPath: string, newPath: string): void; +export function truncate(fd: number, len: number, callback?: (err: Error) => void): void; +export function truncateSync(fd: number, len: number): void; +export function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function chownSync(path: string, uid: number, gid: number): void; +export function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; +export function fchownSync(fd: number, uid: number, gid: number): void; +export function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; +export function lchownSync(path: string, uid: number, gid: number): void; +export function chmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function chmodSync(path: string, mode: number | string): void; +export function fchmod(fd: number, mode: number | string, callback?: (err: Error) => void): void; +export function fchmodSync(fd: number, mode: number | string): void; +export function lchmod(path: string, mode: number | string, callback?: (err: Error) => void): void; +export function lchmodSync(path: string, mode: number | string): void; +export function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; +export function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): 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, callback?: (err: Error) => void): void; +export function linkSync(srcpath: string, dstpath: string): void; +export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; +export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; +export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; +export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; +export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; +export function realpathSync(path: string, cache?: boolean): string; +export function unlink(path: string, callback?: (err: Error) => void): void; +export function unlinkSync(path: string): void; +export function rmdir(path: string, callback?: (err: Error) => void): void; +export function rmdirSync(path: string): void; +export function mkdir(path: string, mode?: number | string, callback?: (err: Error) => void): void; +export function mkdirSync(path: string, mode?: number | string): void; +export function readdir(path: string, callback?: (err: Error, files: string[]) => void): void; +export function readdirSync(path: string): string[]; +export function close(fd: number, callback?: (err: Error) => void): void; +export function closeSync(fd: number): void; +export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; +export function openSync(path: string, flags: string, mode?: string): number; +export function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function utimesSync(path: string, atime: number, mtime: number): void; +export function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; +export function futimesSync(fd: number, atime: number, mtime: number): void; +export function fsync(fd: number, callback?: (err: Error) => void): void; +export function fsyncSync(fd: number): void; +export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; +export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; +export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; +/** + * readFile + * @param filename + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function readFile(filename: string, options: OpenOptions | string, callback: (err: Error, data: string) => void): void; +export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void): void; +export function readFileSync(filename: string): NodeBuffer; +/** + * readFileSync + * @param filename + * @param options + * string: encoding + * OpenOptions: options + */ +export function readFileSync(filename: string, options: OpenOptions | string): string; +/** + * writeFile + * @param filename + * @param data + * @param options + * string: encoding + * OpenOptions: options + * @param callback + */ +export function writeFile(filename: string, data: any, options?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * writeFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function writeFileSync(filename: string, data: any, option?: OpenOptions | string): void; +/** + * appendFile + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: options + * @param callback + */ +export function appendFile(filename: string, data: any, option?: OpenOptions | string, callback?: (err: Error) => void): void; +/** + * appendFileSync + * @param filename + * @param data + * @param option + * string: encoding + * OpenOptions: options + */ +export function appendFileSync(filename: string, data: any, option?: OpenOptions | string): void; +export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; +export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; +export function unwatchFile(filename: string, listener?: Stats): void; +export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; +export function exists(path: string, callback?: (exists: boolean) => void): void; +export function existsSync(path: string): boolean; +export function ensureDir(path: string, cb: (err: Error) => void): void; +export function ensureDirSync(path: string): void; export interface OpenOptions { encoding?: string; flag?: string; } -export declare function createReadStream(path: string | Buffer, options?: { +export function createReadStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; @@ -161,85 +197,90 @@ export declare function createReadStream(path: string | Buffer, options?: { start?: number; end?: number; }): ReadStream; -export declare function createWriteStream(path: string | Buffer, options?: { +export function createWriteStream(path: string | Buffer, options?: { flags?: string; encoding?: string; fd?: number; mode?: number; }): WriteStream; +// promisified versions +export function copyAsync(src: string, dest: string, filter?: (src: string) => boolean): Promise; +export function createFileAsync(file: string): Promise; -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: (src: string) => boolean): Promise; +export function mkdirsAsync(dir: string): Promise; +export function mkdirpAsync(dir: string): Promise; -export declare function createFileAsync(file: string): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function mkdirsAsync(dir: string): Promise; -export declare function mkdirpAsync(dir: string): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function readJSONAsync(file: string, options?: OpenOptions): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; - -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: OpenOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: OpenOptions): Promise; - - -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; // export function deleteAsync(dir: string):Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: OpenOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: OpenOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: string): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: OpenOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: OpenOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: OpenOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: string): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * OpenOptions: options + */ +export function readFileAsync(filename: string, options: OpenOptions | string): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * OpenOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: OpenOptions | string): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param option: + * string: encoding + * OpenOptions: option + */ +export function appendFileAsync(filename: string, data: any, option?: OpenOptions | string): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; -export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; -export declare function isDirectorySync(path: string): boolean; -export declare function isDirectoryAsync(path: string): Promise; +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise-es6/tslint.json b/types/fs-extra-promise-es6/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise-es6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 592f61ca87..9f5a8b32bf 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -1,49 +1,49 @@ import fs = require('fs-extra-promise'); import stream = require('stream'); -var stats: fs.Stats; -var str: string; -var strArr: string[]; -var bool: boolean; -var num: number; -var src: string; -var dest: string; -var file: string; -var filename: string; -var dir: string; -var path: string; -var data: any; -var object: Object; -var buf: Buffer; -var buffer: NodeBuffer; -var modeNum: number; -var modeStr: string; -var encoding: string; -var type: string; -var flags: string; -var srcpath: string; -var dstpath: string; -var oldPath: string; -var newPath: string; -var cache: { [path: string]: string; }; -var offset: number; -var length: number; -var position: number; -var fd: number; -var len: number; -var uid: number; -var gid: number; -var atime: number; -var mtime: number; -var watchListener: (curr: fs.Stats, prev: fs.Stats) => void; -var statsCallback: (err: Error, stats: fs.Stats) => void; -var errorCallback: (err: Error) => void; -var openOpts: fs.ReadOptions; -var writeOpts: fs.WriteOptions; -var watcher: fs.FSWatcher; -var readStream: stream.Readable; -var writeStream: stream.Writable; -var isDirectory: boolean; +let stats: fs.Stats; +let str: string; +let strArr: string[]; +let bool: boolean; +let num: number; +let src: string; +let dest: string; +let file: string; +let filename: string; +let dir: string; +let path: string; +let data: any; +let object: object; +let buf: Buffer; +let buffer: NodeBuffer; +let modeNum: number; +let modeStr: string; +let encoding: string; +let type: string; +let flags: string; +let srcpath: string; +let dstpath: string; +let oldPath: string; +let newPath: string; +let cache: { [path: string]: string; }; +let offset: number; +let length: number; +let position: number; +let fd: number; +let len: number; +let uid: number; +let gid: number; +let atime: number; +let mtime: number; +let watchListener: (curr: fs.Stats, prev: fs.Stats) => void; +let statsCallback: (err: Error, stats: fs.Stats) => void; +let errorCallback: (err: Error) => void; +let openOpts: fs.ReadOptions; +let writeOpts: fs.WriteOptions; +let watcher: fs.FSWatcher; +let readStream: stream.Readable; +let writeStream: stream.Writable; +let isDirectory: boolean; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -123,13 +123,10 @@ fs.linkSync(srcpath, dstpath); fs.symlink(srcpath, dstpath, type, errorCallback); fs.symlinkSync(srcpath, dstpath, type); fs.readlink(path, (err: Error, linkString: string) => { - }); fs.realpath(path, (err: Error, resolvedPath: string) => { - }); fs.realpath(path, cache, (err: Error, resolvedPath: string) => { - }); str = fs.realpathSync(path, cache); fs.unlink(path, errorCallback); @@ -141,13 +138,11 @@ fs.mkdir(path, modeStr, errorCallback); fs.mkdirSync(path, modeNum); fs.mkdirSync(path, modeStr); fs.readdir(path, (err: Error, files: string[]) => { - }); strArr = fs.readdirSync(path); fs.close(fd, errorCallback); fs.closeSync(fd); fs.open(path, flags, modeNum, (err: Error, fd: number) => { - }); num = fs.openSync(path, flags, modeNum); fs.utimes(path, atime, mtime, errorCallback); @@ -157,24 +152,18 @@ fs.futimesSync(fd, atime, mtime); fs.fsync(fd, errorCallback); fs.fsyncSync(fd); fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { - }); num = fs.writeSync(fd, buffer, offset, length, position); fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { - }); num = fs.readSync(fd, buffer, offset, length, position); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); fs.readFile(filename, encoding, (err: Error, data: string) => { - }); fs.readFile(filename, openOpts, (err: NodeJS.ErrnoException, data: Buffer) => { - }); fs.readFile(filename, (err: Error, data: NodeBuffer) => { - }); buffer = fs.readFileSync(filename); str = fs.readFileSync(filename, encoding); @@ -201,10 +190,8 @@ fs.watchFile(filename, { }, watchListener); fs.unwatchFile(filename); watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { - }); fs.exists(path, (exists: boolean) => { - }); bool = fs.existsSync(path); @@ -221,10 +208,9 @@ writeStream = fs.createWriteStream(path, { encoding: str }); -var isDirectoryCallback = (err: Error, isDirectory: boolean) => { +let isDirectoryCallback = (err: Error, isDirectory: boolean) => { }; fs.isDirectory(path, isDirectoryCallback); fs.isDirectory(path); isDirectory = fs.isDirectorySync(path); fs.isDirectoryAsync(path); - diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index 36de7fdf19..d57fd93ed6 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -5,8 +5,6 @@ // TypeScript Version: 2.2 /// -/// -/// import * as stream from 'stream'; import { Stats } from 'fs'; @@ -20,77 +18,94 @@ export interface MkdirOptions { mode?: number; } -//promisified versions -export declare function copyAsync(src: string, dest: string): Promise; -export declare function copyAsync(src: string, dest: string, filter: CopyFilter): Promise; -export declare function copyAsync(src: string, dest: string, options: CopyOptions): Promise; +// promisified versions +/** + * copyAsync + * @param src + * @param dest + * @param options + * CopyFilter: filter + * CopyOptions: options + */ +export function copyAsync(src: string, dest: string, options?: CopyFilter | CopyOptions): Promise; -export declare function createFileAsync(file: string): Promise; +export function createFileAsync(file: string): Promise; -export declare function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; -export declare function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirsAsync(dir: string, options?: MkdirOptions): Promise; +export function mkdirpAsync(dir: string, options?: MkdirOptions): Promise; -export declare function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; +export function moveAsync(src: string, dest: string, options?: MoveOptions): Promise; -export declare function outputFileAsync(file: string, data: any): Promise; +export function outputFileAsync(file: string, data: any): Promise; -export declare function outputJsonAsync(file: string, data: any): Promise; -export declare function outputJSONAsync(file: string, data: any): Promise; +export function outputJsonAsync(file: string, data: any): Promise; +export function outputJSONAsync(file: string, data: any): Promise; -export declare function readJsonAsync(file: string): Promise; -export declare function readJsonAsync(file: string, options?: ReadOptions): Promise; -export declare function readJSONAsync(file: string): Promise; -export declare function readJSONAsync(file: string, options?: ReadOptions): Promise; +export function readJsonAsync(file: string, options?: ReadOptions): Promise; +export function readJSONAsync(file: string, options?: ReadOptions): Promise; -export declare function removeAsync(dir: string): Promise; +export function removeAsync(dir: string): Promise; -export declare function writeJsonAsync(file: string, object: any): Promise; -export declare function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function writeJSONAsync(file: string, object: any): Promise; -export declare function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJsonAsync(file: string, object: any, options?: WriteOptions): Promise; +export function writeJSONAsync(file: string, object: any, options?: WriteOptions): Promise; -export declare function renameAsync(oldPath: string, newPath: string): Promise; -export declare function truncateAsync(fd: number, len: number): Promise; -export declare function chownAsync(path: string, uid: number, gid: number): Promise; -export declare function fchownAsync(fd: number, uid: number, gid: number): Promise; -export declare function lchownAsync(path: string, uid: number, gid: number): Promise; -export declare function chmodAsync(path: string, mode: number): Promise; -export declare function chmodAsync(path: string, mode: string): Promise; -export declare function fchmodAsync(fd: number, mode: number): Promise; -export declare function fchmodAsync(fd: number, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: string): Promise; -export declare function lchmodAsync(path: string, mode: number): Promise; -export declare function statAsync(path: string): Promise; -export declare function lstatAsync(path: string): Promise; -export declare function fstatAsync(fd: number): Promise; -export declare function linkAsync(srcpath: string, dstpath: string): Promise; -export declare function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; -export declare function readlinkAsync(path: string): Promise; -export declare function realpathAsync(path: string): Promise; -export declare function realpathAsync(path: string, cache: { [path: string]: string }): Promise; -export declare function unlinkAsync(path: string): Promise; -export declare function rmdirAsync(path: string): Promise; -export declare function mkdirAsync(path: string, mode?: number): Promise; -export declare function mkdirAsync(path: string, mode?: string): Promise; -export declare function readdirAsync(path: string): Promise; -export declare function closeAsync(fd: number): Promise; -export declare function openAsync(path: string, flags: string, mode?: string): Promise; -export declare function utimesAsync(path: string, atime: number, mtime: number): Promise; -export declare function futimesAsync(fd: number, atime: number, mtime: number): Promise; -export declare function fsyncAsync(fd: number): Promise; -export declare function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; -export declare function readFileAsync(filename: string, encoding: string): Promise; -export declare function readFileAsync(filename: string, options: ReadOptions): Promise; -export declare function readFileAsync(filename: string): Promise; -export declare function writeFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function writeFileAsync(filename: string, data: any, options?: WriteOptions): Promise; -export declare function appendFileAsync(filename: string, data: any, encoding?: string): Promise; -export declare function appendFileAsync(filename: string, data: any, option?: WriteOptions): Promise; +export function renameAsync(oldPath: string, newPath: string): Promise; +export function truncateAsync(fd: number, len: number): Promise; +export function chownAsync(path: string, uid: number, gid: number): Promise; +export function fchownAsync(fd: number, uid: number, gid: number): Promise; +export function lchownAsync(path: string, uid: number, gid: number): Promise; +export function chmodAsync(path: string, mode: number | string): Promise; +export function fchmodAsync(fd: number, mode: number | string): Promise; +export function lchmodAsync(path: string, mode: number | string): Promise; +export function statAsync(path: string): Promise; +export function lstatAsync(path: string): Promise; +export function fstatAsync(fd: number): Promise; +export function linkAsync(srcpath: string, dstpath: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function readlinkAsync(path: string): Promise; +export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise; +export function unlinkAsync(path: string): Promise; +export function rmdirAsync(path: string): Promise; +export function mkdirAsync(path: string, mode?: number | string): Promise; +export function readdirAsync(path: string): Promise; +export function closeAsync(fd: number): Promise; +export function openAsync(path: string, flags: string, mode?: string): Promise; +export function utimesAsync(path: string, atime: number, mtime: number): Promise; +export function futimesAsync(fd: number, atime: number, mtime: number): Promise; +export function fsyncAsync(fd: number): Promise; +export function writeAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +export function readAsync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): Promise<[number, NodeBuffer]>; +/** + * readFileAsync + * @param filename + * @param options: + * string: encoding + * ReadOptions: options + */ +export function readFileAsync(filename: string, options: string | ReadOptions): Promise; +export function readFileAsync(filename: string): Promise; +/** + * writeFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function writeFileAsync(filename: string, data: any, options?: string | WriteOptions): Promise; +/** + * appendFileAsync + * @param filename + * @param data + * @param options: + * string: encoding + * WriteOptions: options + */ +export function appendFileAsync(filename: string, data: any, option?: string | WriteOptions): Promise; -export declare function existsAsync(path: string): Promise; -export declare function ensureDirAsync(path: string): Promise; +export function existsAsync(path: string): Promise; +export function ensureDirAsync(path: string): Promise; -export declare function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; -export declare function isDirectorySync(path: string): boolean; -export declare function isDirectoryAsync(path: string): Promise; +export function isDirectory(path: string, callback?: (err: Error, isDirectory: boolean) => void): void; +export function isDirectorySync(path: string): boolean; +export function isDirectoryAsync(path: string): Promise; diff --git a/types/fs-extra-promise/tslint.json b/types/fs-extra-promise/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-extra-promise/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}