Merge pull request #21432 from mrmlnc/fix_glob_stream

[glob-stream] Update definitions to the current version of package
This commit is contained in:
Armando Aguirre
2017-12-01 14:43:53 -08:00
committed by GitHub
2 changed files with 58 additions and 19 deletions

View File

@@ -2,9 +2,24 @@ import gs = require('glob-stream');
var read: NodeJS.ReadableStream;
read = gs.create('xx');
read = gs.create('xx', {});
read = gs.create(['xx'], {});
read = gs.create(['xx'], {cwd: 'xx'});
read = gs.create(['xx'], {base: 'xx'});
read = gs.create(['xx'], {cwdbase: true});
// Types
var strPredicate: gs.UniqueByStringPredicate = 'base';
var fnPredicate: gs.UniqueByFunctionPredicate = (entry) => entry.path;
// Base cases
read = gs('xx');
read = gs('xx', {});
read = gs(['xx'], {});
// Package options
read = gs(['xx'], { allowEmpty: true });
read = gs(['xx'], { base: 'xx' });
read = gs(['xx'], { cwdbase: true });
read = gs(['xx'], { uniqueBy: 'path' });
read = gs(['xx'], { uniqueBy: 'base' });
read = gs(['xx'], { uniqueBy: 'cwd' });
read = gs(['xx'], { uniqueBy: (entry: gs.Entry) => entry.path });
// Glob options
read = gs(['xx'], { root: 'root' });
read = gs(['xx'], { debug: true });

View File

@@ -1,6 +1,7 @@
// Type definitions for glob-stream v3.1.12
// Type definitions for glob-stream v6.1.0
// Project: https://github.com/wearefractal/glob-stream
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// mrmlnc <https://github.com/mrmlnc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -8,17 +9,40 @@
import glob = require('glob');
export interface Options extends glob.IOptions {
cwd?: string;
base?: string;
cwdbase?: boolean;
declare function GlobStream(glob: string | string[]): NodeJS.ReadableStream;
declare function GlobStream(glob: string | string[], options: GlobStream.Options): NodeJS.ReadableStream;
declare namespace GlobStream {
export interface Entry {
cwd: string;
base: string;
path: string;
}
export type UniqueByStringPredicate = 'cwd' | 'base' | 'path';
export type UniqueByFunctionPredicate = (entry: Entry) => string;
export interface Options extends glob.IOptions {
/**
* Whether or not to error upon an empty singular glob.
*/
allowEmpty?: boolean;
/**
* The absolute segment of the glob path that isn't a glob. This value is attached
* to each globobject and is useful for relative pathing.
*/
base?: string;
/**
* Whether or not the `cwd` and `base` should be the same.
*/
cwdbase?: boolean;
/**
* Filters stream to remove duplicates based on the string property name or the result of function.
* When using a function, the function receives the streamed
* data (objects containing `cwd`, `base`, `path` properties) to compare against.
*/
uniqueBy?: UniqueByStringPredicate | UniqueByFunctionPredicate;
}
}
export interface Element {
cwd: string;
base: string;
path: string;
}
export declare function create(glob: string, opts?: Options): NodeJS.ReadableStream;
export declare function create(globs: string[], opts?: Options): NodeJS.ReadableStream;
export = GlobStream;