diff --git a/index.d.ts b/index.d.ts index 1e2448b..2e563fc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import {Options as FastGlobOptions} from 'fast-glob'; +import {Options as FastGlobOptions, Entry as FastGlobEntry} from 'fast-glob'; declare namespace globby { type ExpandDirectoriesOption = @@ -6,6 +6,8 @@ declare namespace globby { | readonly string[] | {files?: readonly string[]; extensions?: readonly string[]}; + type Entry = FastGlobEntry; + interface GlobbyOptions extends FastGlobOptions { /** 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: { @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package. @returns The matching paths. */ - sync: ( + sync: (( + patterns: string | readonly string[], + options: globby.GlobbyOptions & {objectMode: true} + ) => globby.Entry[]) & (( patterns: string | readonly string[], options?: globby.GlobbyOptions - ) => string[]; + ) => string[]); /** Find files and directories using glob patterns. @@ -146,6 +151,11 @@ declare const globby: { readonly gitignore: Gitignore; + ( + patterns: string | readonly string[], + options: globby.GlobbyOptions & {objectMode: true} + ): Promise; + /** Find files and directories using glob patterns. diff --git a/index.test-d.ts b/index.test-d.ts index 2c0dd03..3681c25 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -28,6 +28,7 @@ expectType>( ); expectType>(globby('*.tmp', {gitignore: true})); expectType>(globby('*.tmp', {ignore: ['**/b.tmp']})); +expectType>(globby('*.tmp', {objectMode: true})); // Globby (sync) expectType(globbySync('*.tmp')); @@ -45,6 +46,7 @@ expectType( ); expectType(globbySync('*.tmp', {gitignore: true})); expectType(globbySync('*.tmp', {ignore: ['**/b.tmp']})); +expectType(globbySync('*.tmp', {objectMode: true})); // Globby (stream) expectType(globbyStream('*.tmp'));