Skip to content

Commit

Permalink
fix: Add GlobSourceResult to globSource return type in unixfs. (#475)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
saul-jb authored Mar 27, 2024
1 parent d1c497b commit 9ac5909
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/unixfs/src/utils/glob-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import glob from 'it-glob'
import { InvalidParametersError } from '../errors.js'
import { toMtime } from './to-mtime.js'
import type { MtimeLike } from 'ipfs-unixfs'
import type { ImportCandidateStream } from 'ipfs-unixfs-importer'
import type { ImportCandidate } from 'ipfs-unixfs-importer'

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

0 comments on commit 9ac5909

Please sign in to comment.