mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add npm library fs-finder
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/// <reference path="fs-finder.d.ts" />
|
||||
|
||||
import finder = require('fs-finder');
|
||||
|
||||
|
||||
// static
|
||||
var a: FsFinder.Finder = finder.in('./*');
|
||||
|
||||
var b: FsFinder.Finder = finder.from('./*');
|
||||
|
||||
var c: FsFinder.Finder = finder.find('./*');
|
||||
finder.find('./*', (paths: string[]) => {});
|
||||
|
||||
var d: FsFinder.Finder = finder.findFiles('./*');
|
||||
finder.findFiles('./*', (paths: string[]) => {});
|
||||
|
||||
var e: FsFinder.Finder = finder.findDirectories('./*');
|
||||
finder.findDirectories('./*', (paths: string[]) => {});
|
||||
|
||||
var f: FsFinder.Finder = finder.findFile('./*');
|
||||
finder.findFile('./*', (paths: string[]) => {});
|
||||
|
||||
var g: FsFinder.Finder = finder.findDirectory('./*');
|
||||
finder.findDirectory('./*', (paths: string[]) => {});
|
||||
|
||||
|
||||
// instance
|
||||
var instance = finder.in('./any*');
|
||||
|
||||
var j: string[] = instance.find('./*');
|
||||
instance.find('./*', (paths: string[]) => {});
|
||||
|
||||
var k: string[] = instance.findFiles('./*');
|
||||
instance.findFiles('./*', (paths: string[]) => {});
|
||||
|
||||
var l: string[] = instance.findDirectories('./*');
|
||||
instance.findDirectories('./*', (paths: string[]) => {});
|
||||
|
||||
var m: string[] = instance.findFile('./*');
|
||||
instance.findFile('./*', (paths: string[]) => {});
|
||||
|
||||
var n: string[] = instance.findDirectory('./*');
|
||||
instance.findDirectory('./*', (paths: string[]) => {});
|
||||
|
||||
var paths: string[];
|
||||
paths = instance.find();
|
||||
paths = instance.findFiles();
|
||||
paths = instance.findDirectories();
|
||||
paths = instance.findFile();
|
||||
paths = instance.findDirectory();
|
||||
|
||||
|
||||
// Base
|
||||
instance = instance.recursively();
|
||||
instance = instance.recursively(false);
|
||||
instance = instance.exclude('b');
|
||||
instance = instance.exclude(['b']);
|
||||
instance = instance.exclude('a', true);
|
||||
instance = instance.showSystemFiles();
|
||||
instance = instance.showSystemFiles(false);
|
||||
instance = instance.lookUp();
|
||||
instance = instance.lookUp(false);
|
||||
instance = instance.findFirst();
|
||||
instance = instance.findFirst(true);
|
||||
instance = instance.filter((path: string) => {
|
||||
return false;
|
||||
});
|
||||
|
||||
paths = instance.getPathsSync('all', './*', './dir');
|
||||
instance.getPathsAsync((paths: string[]) => {}, 'all', './*', './dir');
|
||||
paths = instance.getPathsSync('directories', './*', './dir');
|
||||
instance.getPathsAsync((paths: string[]) => {}, 'directories', './*', './dir');
|
||||
paths = instance.getPathsSync('files', './*', './dir');
|
||||
instance.getPathsAsync((paths: string[]) => {}, 'files', './*', './dir');
|
||||
|
||||
var is: boolean;
|
||||
is = instance.checkExcludes('a');
|
||||
is = instance.checkSystemFiles('b');
|
||||
is = instance.checkFilters('c', {});
|
||||
|
||||
var numeric: number;
|
||||
numeric = instance.checkFile('d', {}, './*.ts', 'all');
|
||||
numeric = instance.checkFile('d', {}, './*.ts', 'directories');
|
||||
numeric = instance.checkFile('d', {}, './*.ts', 'files');
|
||||
|
||||
paths = instance.getPathsFromParentsSync('a', 'all');
|
||||
instance.getPathsFromParentsAsync((paths: string[]) => {}, '*.ts', 'all');
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
// Type definitions for fs-finder v1.8.0
|
||||
// Project: https://github.com/sakren/node-fs-finder
|
||||
// Definitions by: Michael Zabka <https://github.com/misak113/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module FsFinder {
|
||||
|
||||
type AsyncFunction = (paths: string|string[]) => void;
|
||||
type Type = string; // 'all'|'directories'|'files'
|
||||
type Mask = string;
|
||||
type Directory = string;
|
||||
|
||||
export class Finder extends Base {
|
||||
static TIME_FORMAT: string;
|
||||
static in(path: string): Finder;
|
||||
static from(path: string): Finder;
|
||||
static find(path: string, fn?: AsyncFunction, type?: Type): Finder;
|
||||
static findFiles(path?: string, fn?: AsyncFunction): Finder;
|
||||
static findDirectories(path?: string, fn?: AsyncFunction): Finder;
|
||||
static findFile(path?: string, fn?: AsyncFunction): Finder;
|
||||
static findDirectory(path?: string, fn?: AsyncFunction): Finder;
|
||||
find(mask?: Mask, fn?: AsyncFunction, type?: Type): string[];
|
||||
findFiles(mask?: Mask, fn?: AsyncFunction): string[];
|
||||
findDirectories(mask?: Mask, fn?: AsyncFunction): string[];
|
||||
findFile(mask?: Mask, fn?: AsyncFunction): string[];
|
||||
findDirectory(mask?: Mask, fn?: AsyncFunction): string[];
|
||||
size(operation?: any, value?: any): Finder;
|
||||
date(operation?: any, value?: any): Finder;
|
||||
}
|
||||
|
||||
export class Base {
|
||||
recursively(recursive?: boolean): Finder;
|
||||
exclude(excludes: string|string[], exactly?: boolean): Finder;
|
||||
showSystemFiles(systemFiles?: boolean): Finder;
|
||||
lookUp(up?: boolean): Finder;
|
||||
findFirst(findFirst?: boolean): Finder;
|
||||
filter(fn: Function): Finder;
|
||||
|
||||
getPathsSync(type?: Type, mask?: Mask, dir?: Directory): string[];
|
||||
getPathsAsync(fn: AsyncFunction, type?: Type, mask?: Mask, dir?: Directory): void;
|
||||
|
||||
checkExcludes(path: string): boolean;
|
||||
checkSystemFiles(path: string): boolean;
|
||||
checkFilters(path: string, stats: any): boolean;
|
||||
checkFile(path: string, stats: any, mask: Mask, type: Type): number;
|
||||
|
||||
getPathsFromParentsSync(mask?: Mask, type?: Type): string[];
|
||||
getPathsFromParentsAsync(fn: AsyncFunction, mask?: Mask, type?: Type): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "fs-finder" {
|
||||
import Finder = FsFinder.Finder;
|
||||
export = Finder;
|
||||
}
|
||||
Reference in New Issue
Block a user