Skip to content

Commit a08264f

Browse files
Support objectMode option in the TypeScript types (#178)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent c1a3b32 commit a08264f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

index.d.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import {Options as FastGlobOptions} from 'fast-glob';
1+
import {Options as FastGlobOptions, Entry as FastGlobEntry} from 'fast-glob';
22

33
declare namespace globby {
44
type ExpandDirectoriesOption =
55
| boolean
66
| readonly string[]
77
| {files?: readonly string[]; extensions?: readonly string[]};
88

9+
type Entry = FastGlobEntry;
10+
911
interface GlobbyOptions extends FastGlobOptions {
1012
/**
1113
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 in the example below.
@@ -88,10 +90,13 @@ declare const globby: {
8890
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
8991
@returns The matching paths.
9092
*/
91-
sync: (
93+
sync: ((
94+
patterns: string | readonly string[],
95+
options: globby.GlobbyOptions & {objectMode: true}
96+
) => globby.Entry[]) & ((
9297
patterns: string | readonly string[],
9398
options?: globby.GlobbyOptions
94-
) => string[];
99+
) => string[]);
95100

96101
/**
97102
Find files and directories using glob patterns.
@@ -146,6 +151,11 @@ declare const globby: {
146151

147152
readonly gitignore: Gitignore;
148153

154+
(
155+
patterns: string | readonly string[],
156+
options: globby.GlobbyOptions & {objectMode: true}
157+
): Promise<globby.Entry[]>;
158+
149159
/**
150160
Find files and directories using glob patterns.
151161

index.test-d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ expectType<Promise<string[]>>(
2828
);
2929
expectType<Promise<string[]>>(globby('*.tmp', {gitignore: true}));
3030
expectType<Promise<string[]>>(globby('*.tmp', {ignore: ['**/b.tmp']}));
31+
expectType<Promise<globby.Entry[]>>(globby('*.tmp', {objectMode: true}));
3132

3233
// Globby (sync)
3334
expectType<string[]>(globbySync('*.tmp'));
@@ -45,6 +46,7 @@ expectType<string[]>(
4546
);
4647
expectType<string[]>(globbySync('*.tmp', {gitignore: true}));
4748
expectType<string[]>(globbySync('*.tmp', {ignore: ['**/b.tmp']}));
49+
expectType<globby.Entry[]>(globbySync('*.tmp', {objectMode: true}));
4850

4951
// Globby (stream)
5052
expectType<NodeJS.ReadableStream>(globbyStream('*.tmp'));

0 commit comments

Comments
 (0)