Skip to content

Commit

Permalink
feat: pass file name to add/addAll progress handler (#3372)
Browse files Browse the repository at this point in the history
Since ipfs/js-ipfs-unixfs#87 landed we can now pass the file name to
the progress handler for adding files:

```js
await ipfs.addAll(..., {
  progress: (bytes, fileName) => {
    //...
  }
})
```

This should make showing progress a bit more usable.

Co-authored-by: Hugo Dias <[email protected]>
  • Loading branch information
achingbrain and hugomrdias authored Nov 6, 2020
1 parent 933ea01 commit 0903f10
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = configure((api) => {
if (file.hash !== undefined) {
yield toCoreInterface(file)
} else if (progressFn) {
progressFn(file.bytes || 0)
progressFn(file.bytes || 0, file.name)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = ipfsClient
* derives API from it's return type and extends it last `options` parameter
* with `HttpOptions`.
*
* This can be used to avoid (re)typing API interface when implemeting it in
* This can be used to avoid (re)typing API interface when implementing it in
* http client e.g you can annotate `ipfs.addAll` implementation with
*
* `@type {Implements<typeof import('ipfs-core/src/components/add-all')>}`
Expand All @@ -83,7 +83,7 @@ module.exports = ipfsClient
/**
* @template Key
* @template {(config:any) => any} APIFactory
* @typedef {import('./interface').APIMethadWithExtraOptions<ReturnType<APIFactory>, Key, HttpOptions>} ImplementsMethod
* @typedef {import('./interface').APIMethodWithExtraOptions<ReturnType<APIFactory>, Key, HttpOptions>} ImplementsMethod
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file contains some utility types that either can't be expressed in
// JSDoc syntax or that result in a different behavior when typed in JSDoc.
// JSDoc syntax or that result in a different behaviour when typed in JSDoc.

/**
* Utility type that takes IPFS Core API function type (with 0 to 4 arguments
Expand Down Expand Up @@ -51,7 +51,7 @@ type WithExtendedOptions<Params, Ext> = Params extends [...End]
? [a1?: A1, a2?: A2, a3?: A3, options?: Options & Ext]
: never

export type APIMethadWithExtraOptions <
export type APIMethodWithExtraOptions <
API,
Key extends keyof API,
Extra
Expand Down

0 comments on commit 0903f10

Please sign in to comment.