Merge pull request #10938 from zlumer/patch-2

node-dir: added types for callback params
This commit is contained in:
Andy
2016-09-20 09:19:38 -07:00
committed by GitHub
2 changed files with 18 additions and 11 deletions
+1
View File
@@ -1,3 +1,4 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="node-dir.d.ts" />
import * as dir from "node-dir";
+17 -11
View File
@@ -2,8 +2,11 @@
// Project: https://github.com/fshost/node-dir
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../node/node.d.ts"/>
declare module "node-dir" {
import { ReadStream } from "fs";
export interface Options {
// file encoding (defaults to 'utf8')
encoding?: string;
@@ -37,29 +40,32 @@ declare module "node-dir" {
}
export interface FileCallback {
(error: any, content: any, next: () => void): void;
(error: any, content: string | Buffer, next: () => void): void;
}
export interface FileNamedCallback {
(error: any, content: any, filename: string, next: () => void): void;
(error: any, content: string | Buffer, filename: string, next: () => void): void;
}
export interface StreamCallback {
(error: any, stream: any, next: () => void): void;
(error: any, stream: ReadStream, next: () => void): void;
}
export interface FinishedCallback {
(error: any, files: any): void;
(error: any, files: string[]): void;
}
export interface PathsResult {
files: string[];
dirs: string[];
}
export function readFiles(dir: string, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileCallback, finishedCallback?: FinishedCallback): void;
export function readFiles(dir: string, options: Options, fileCallback: FileNamedCallback, finishedCallback?: FinishedCallback): void;
export function readFilesStream(dir: string, options: Options, streamCallback: StreamCallback,
finishedCallback?: FinishedCallback): void;
export function files(dir: string, callback: (error: any, files: any) => void): void;
export function subdirs(dir: string, callback: (error: any, subdirs: any) => void): void;
export function paths(dir: string, callback: (error: any, paths: any) => void): void;
export function paths(dir: string, combine: boolean, callback: (error: any, paths: any) => void): void;
export function readFilesStream(dir: string, options: Options, streamCallback: StreamCallback, finishedCallback?: FinishedCallback): void;
export function files(dir: string, callback: (error: any, files: string[]) => void): void;
export function subdirs(dir: string, callback: (error: any, subdirs: string[]) => void): void;
export function paths(dir: string, callback: (error: any, paths: PathsResult) => void): void;
export function paths(dir: string, combine: boolean, callback: (error: any, paths: string[] | PathsResult) => void): void;
}