You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: index.d.ts
+21
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,27 @@ declare const globby: {
111
111
options?: globby.GlobbyOptions
112
112
): string[];
113
113
114
+
/**
115
+
@param patterns - See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
116
+
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-1) in addition to the ones in this package.
117
+
@returns The stream of matching paths.
118
+
119
+
@example
120
+
```
121
+
import globby = require('globby');
122
+
123
+
(async () => {
124
+
for await (const path of globby.stream('*.tmp')) {
125
+
console.log(path);
126
+
}
127
+
})();
128
+
```
129
+
*/
130
+
stream(
131
+
patterns: string|readonlystring[],
132
+
options?: globby.GlobbyOptions
133
+
): NodeJS.ReadableStream;
134
+
114
135
/**
115
136
Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
Copy file name to clipboardexpand all lines: readme.md
+18
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,8 @@ Default: `true`
67
67
If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `object` with `files` and `extensions` like below:
68
68
69
69
```js
70
+
constglobby=require('globby');
71
+
70
72
(async () => {
71
73
constpaths=awaitglobby('images', {
72
74
expandDirectories: {
@@ -93,6 +95,22 @@ Respect ignore patterns in `.gitignore` files that apply to the globbed files.
93
95
94
96
Returns `string[]` of matching paths.
95
97
98
+
### globby.stream(patterns, options?)
99
+
100
+
Returns a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) of matching paths.
101
+
102
+
Since Node.js 10, [readable streams are iterable](https://nodejs.org/api/stream.html#stream_readable_symbol_asynciterator), so you can loop over glob matches in a [`for await...of` loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) like this:
103
+
104
+
```js
105
+
constglobby=require('globby');
106
+
107
+
(async () => {
108
+
forawait (constpathofglobby.stream('*.tmp')) {
109
+
console.log(path);
110
+
}
111
+
})();
112
+
```
113
+
96
114
### globby.generateGlobTasks(patterns, options?)
97
115
98
116
Returns an `object[]` in the format `{pattern: string, options: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
0 commit comments