From 0903f102775b90e6cfe58f861ecbce43f10c4c0e Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Fri, 6 Nov 2020 14:18:35 +0000 Subject: [PATCH] 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 --- src/add-all.js | 2 +- src/index.js | 4 ++-- src/interface.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/add-all.js b/src/add-all.js index ba226c857..0ef589ee8 100644 --- a/src/add-all.js +++ b/src/add-all.js @@ -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) } } } diff --git a/src/index.js b/src/index.js index 65e7d7c48..11c2ad9d9 100644 --- a/src/index.js +++ b/src/index.js @@ -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}` @@ -83,7 +83,7 @@ module.exports = ipfsClient /** * @template Key * @template {(config:any) => any} APIFactory - * @typedef {import('./interface').APIMethadWithExtraOptions, Key, HttpOptions>} ImplementsMethod + * @typedef {import('./interface').APIMethodWithExtraOptions, Key, HttpOptions>} ImplementsMethod */ /** diff --git a/src/interface.ts b/src/interface.ts index 34b698cc9..6258fbd83 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -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 @@ -51,7 +51,7 @@ type WithExtendedOptions = 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