Skip to content

Commit 9ac5909

Browse files
authored
fix: Add GlobSourceResult to globSource return type in unixfs. (#475)
Modifies the return type on the `globSource` utility in `@helia/unixfs` to return the `GlobSourceResult` in addition to the `ImportCandidate` type. This means that the `path` property will be a `string` instead of `string | undefined`. Makes it a bit easier to use `globSource` since it is a bit annoying to have to check if `path` is defined when it always is.
1 parent d1c497b commit 9ac5909

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/unixfs/src/utils/glob-source.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import glob from 'it-glob'
55
import { InvalidParametersError } from '../errors.js'
66
import { toMtime } from './to-mtime.js'
77
import type { MtimeLike } from 'ipfs-unixfs'
8-
import type { ImportCandidateStream } from 'ipfs-unixfs-importer'
8+
import type { ImportCandidate } from 'ipfs-unixfs-importer'
99

1010
export interface GlobSourceOptions {
1111
/**
@@ -49,7 +49,7 @@ export interface GlobSourceResult {
4949
/**
5050
* Create an async iterator that yields paths that match requested glob pattern
5151
*/
52-
export async function * globSource (cwd: string, pattern: string, options: GlobSourceOptions = {}): ImportCandidateStream {
52+
export async function * globSource (cwd: string, pattern: string, options: GlobSourceOptions = {}): AsyncGenerator<ImportCandidate & GlobSourceResult> {
5353
if (typeof pattern !== 'string') {
5454
throw new InvalidParametersError('Pattern must be a string')
5555
}

0 commit comments

Comments
 (0)