@@ -13,19 +13,9 @@ type EntryObjectModePredicate = { [P in keyof Pick<Options, 'objectMode'>]-?: tr
1313type EntryStatsPredicate = { [ P in keyof Pick < Options , 'stats' > ] -?: true } ;
1414type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate ;
1515
16- function sync ( source : Pattern | Pattern [ ] , options : Options & EntryObjectPredicate ) : Entry [ ] ;
17- function sync ( source : Pattern | Pattern [ ] , options ?: Options ) : string [ ] ;
18- function sync ( source : Pattern | Pattern [ ] , options ?: Options ) : EntryItem [ ] {
19- assertPatternsInput ( source ) ;
20-
21- const works = getWorks ( source , ProviderSync , options ) ;
22-
23- return utils . array . flatten ( works ) ;
24- }
25-
26- function async ( source : Pattern | Pattern [ ] , options : Options & EntryObjectPredicate ) : Promise < Entry [ ] > ;
27- function async ( source : Pattern | Pattern [ ] , options ?: Options ) : Promise < string [ ] > ;
28- function async ( source : Pattern | Pattern [ ] , options ?: Options ) : Promise < EntryItem [ ] > {
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 [ ] > {
2919 try {
3020 assertPatternsInput ( source ) ;
3121 } catch ( error ) {
@@ -37,26 +27,38 @@ function async(source: Pattern | Pattern[], options?: Options): Promise<EntryIte
3727 return Promise . all ( works ) . then ( utils . array . flatten ) ;
3828}
3929
40- function stream ( source : Pattern | Pattern [ ] , options ?: Options ) : NodeJS . ReadableStream {
41- assertPatternsInput ( source ) ;
30+ 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 [ ] {
34+ assertPatternsInput ( source ) ;
4235
43- const works = getWorks ( source , ProviderStream , options ) ;
36+ const works = getWorks ( source , ProviderSync , options ) ;
4437
45- /**
46- * The stream returned by the provider cannot work with an asynchronous iterator.
47- * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
48- * This affects performance (+25%). I don't see best solution right now.
49- */
50- return utils . stream . merge ( works ) ;
51- }
38+ return utils . array . flatten ( works ) ;
39+ }
40+
41+ export function stream ( source : Pattern | Pattern [ ] , options ?: Options ) : NodeJS . ReadableStream {
42+ assertPatternsInput ( source ) ;
5243
53- function generateTasks ( source : Pattern | Pattern [ ] , options ?: Options ) : Task [ ] {
54- assertPatternsInput ( source ) ;
44+ const works = getWorks ( source , ProviderStream , options ) ;
5545
56- const patterns = ( [ ] as Pattern [ ] ) . concat ( source ) ;
57- const settings = new Settings ( options ) ;
46+ /**
47+ * The stream returned by the provider cannot work with an asynchronous iterator.
48+ * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams.
49+ * This affects performance (+25%). I don't see best solution right now.
50+ */
51+ return utils . stream . merge ( works ) ;
52+ }
5853
59- return taskManager . generate ( patterns , settings ) ;
54+ export function generateTasks ( source : Pattern | Pattern [ ] , options ?: Options ) : Task [ ] {
55+ assertPatternsInput ( source ) ;
56+
57+ const patterns = ( [ ] as Pattern [ ] ) . concat ( source ) ;
58+ const settings = new Settings ( options ) ;
59+
60+ return taskManager . generate ( patterns , settings ) ;
61+ }
6062}
6163
6264function getWorks < T > ( source : Pattern | Pattern [ ] , _Provider : new ( settings : Settings ) => Provider < T > , options ?: Options ) : T [ ] {
@@ -82,15 +84,4 @@ function isString(source: unknown): source is string {
8284 return typeof source === 'string' ;
8385}
8486
85- export default async ;
86- export {
87- async ,
88- sync ,
89- stream ,
90- generateTasks ,
91-
92- Options ,
93- Settings ,
94- Task ,
95- EntryItem
96- } ;
87+ export = FastGlob ;
0 commit comments