Skip to content

Commit 0903f10

Browse files
feat: pass file name to add/addAll progress handler (#3372)
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]>
1 parent 933ea01 commit 0903f10

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/add-all.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = configure((api) => {
3838
if (file.hash !== undefined) {
3939
yield toCoreInterface(file)
4040
} else if (progressFn) {
41-
progressFn(file.bytes || 0)
41+
progressFn(file.bytes || 0, file.name)
4242
}
4343
}
4444
}

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = ipfsClient
6868
* derives API from it's return type and extends it last `options` parameter
6969
* with `HttpOptions`.
7070
*
71-
* This can be used to avoid (re)typing API interface when implemeting it in
71+
* This can be used to avoid (re)typing API interface when implementing it in
7272
* http client e.g you can annotate `ipfs.addAll` implementation with
7373
*
7474
* `@type {Implements<typeof import('ipfs-core/src/components/add-all')>}`
@@ -83,7 +83,7 @@ module.exports = ipfsClient
8383
/**
8484
* @template Key
8585
* @template {(config:any) => any} APIFactory
86-
* @typedef {import('./interface').APIMethadWithExtraOptions<ReturnType<APIFactory>, Key, HttpOptions>} ImplementsMethod
86+
* @typedef {import('./interface').APIMethodWithExtraOptions<ReturnType<APIFactory>, Key, HttpOptions>} ImplementsMethod
8787
*/
8888

8989
/**

src/interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This file contains some utility types that either can't be expressed in
2-
// JSDoc syntax or that result in a different behavior when typed in JSDoc.
2+
// JSDoc syntax or that result in a different behaviour when typed in JSDoc.
33

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

54-
export type APIMethadWithExtraOptions <
54+
export type APIMethodWithExtraOptions <
5555
API,
5656
Key extends keyof API,
5757
Extra

0 commit comments

Comments
 (0)