Skip to content

Commit c1d686c

Browse files
committed
refactor(index): export some userful types
1 parent d64c24f commit c1d686c

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

src/index.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ import ProviderAsync from './providers/async';
33
import Provider from './providers/provider';
44
import ProviderStream from './providers/stream';
55
import ProviderSync from './providers/sync';
6-
import Settings, { Options } from './settings';
7-
import { Entry, EntryItem, Pattern } from './types/index';
6+
import Settings, { Options as OptionsInternal } from './settings';
7+
import { Entry as EntryInternal, EntryItem, FileSystemAdapter as FileSystemAdapterInternal, Pattern as PatternInternal } from './types/index';
88
import * as utils from './utils/index';
99

10-
type Task = taskManager.Task;
11-
12-
type EntryObjectModePredicate = { [P in keyof Pick<Options, 'objectMode'>]-?: true };
13-
type EntryStatsPredicate = { [P in keyof Pick<Options, 'stats'>]-?: true };
10+
type EntryObjectModePredicate = { [P in keyof Pick<OptionsInternal, 'objectMode'>]-?: true };
11+
type EntryStatsPredicate = { [P in keyof Pick<OptionsInternal, 'stats'>]-?: true };
1412
type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate;
1513

16-
function FastGlob(source: Pattern | Pattern[], options: Options & EntryObjectPredicate): Promise<Entry[]>;
17-
function FastGlob(source: Pattern | Pattern[], options?: Options): Promise<string[]>;
18-
function FastGlob(source: Pattern | Pattern[], options?: Options): Promise<EntryItem[]> {
14+
function FastGlob(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): Promise<EntryInternal[]>;
15+
function FastGlob(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Promise<string[]>;
16+
function FastGlob(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Promise<EntryItem[]> {
1917
try {
2018
assertPatternsInput(source);
2119
} catch (error) {
@@ -28,17 +26,23 @@ function FastGlob(source: Pattern | Pattern[], options?: Options): Promise<Entry
2826
}
2927

3028
namespace FastGlob {
31-
export function sync(source: Pattern | Pattern[], options: Options & EntryObjectPredicate): Entry[];
32-
export function sync(source: Pattern | Pattern[], options?: Options): string[];
33-
export function sync(source: Pattern | Pattern[], options?: Options): EntryItem[] {
29+
export type Options = OptionsInternal;
30+
export type Entry = EntryInternal;
31+
export type Task = taskManager.Task;
32+
export type Pattern = PatternInternal;
33+
export type FileSystemAdapter = FileSystemAdapterInternal;
34+
35+
export function sync(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): EntryInternal[];
36+
export function sync(source: PatternInternal | PatternInternal[], options?: OptionsInternal): string[];
37+
export function sync(source: PatternInternal | PatternInternal[], options?: OptionsInternal): EntryItem[] {
3438
assertPatternsInput(source);
3539

3640
const works = getWorks(source, ProviderSync, options);
3741

3842
return utils.array.flatten(works);
3943
}
4044

41-
export function stream(source: Pattern | Pattern[], options?: Options): NodeJS.ReadableStream {
45+
export function stream(source: PatternInternal | PatternInternal[], options?: OptionsInternal): NodeJS.ReadableStream {
4246
assertPatternsInput(source);
4347

4448
const works = getWorks(source, ProviderStream, options);
@@ -51,18 +55,18 @@ namespace FastGlob {
5155
return utils.stream.merge(works);
5256
}
5357

54-
export function generateTasks(source: Pattern | Pattern[], options?: Options): Task[] {
58+
export function generateTasks(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Task[] {
5559
assertPatternsInput(source);
5660

57-
const patterns = ([] as Pattern[]).concat(source);
61+
const patterns = ([] as PatternInternal[]).concat(source);
5862
const settings = new Settings(options);
5963

6064
return taskManager.generate(patterns, settings);
6165
}
6266
}
6367

64-
function getWorks<T>(source: Pattern | Pattern[], _Provider: new (settings: Settings) => Provider<T>, options?: Options): T[] {
65-
const patterns = ([] as Pattern[]).concat(source);
68+
function getWorks<T>(source: PatternInternal | PatternInternal[], _Provider: new (settings: Settings) => Provider<T>, options?: OptionsInternal): T[] {
69+
const patterns = ([] as PatternInternal[]).concat(source);
6670
const settings = new Settings(options);
6771

6872
const tasks = taskManager.generate(patterns, settings);

0 commit comments

Comments
 (0)