From b577146711fa5710dc3189277d3a333c68a269ff Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Thu, 31 Mar 2022 15:41:45 +0900 Subject: [PATCH 1/9] Support progressive reporting --- index.d.ts | 26 +++++++++++++++++++- index.js | 65 +++++++++++++++++++++++++++++++++++++------------ index.test-d.ts | 13 +++++----- readme.md | 30 +++++++++++++++++++++++ test.js | 36 +++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 23 deletions(-) diff --git a/index.d.ts b/index.d.ts index be9f392..fc20448 100644 --- a/index.d.ts +++ b/index.d.ts @@ -34,6 +34,30 @@ declare namespace del { */ readonly concurrency?: number; } + + interface ProgressData { + /** + Deleted file count. + */ + deletedFiles: number; + + /** + Overall file count. + */ + totalFiles: number; + + /** + Completed percentage. A value between `0` and `1`. + */ + percent: number; + } + + interface ProgressEmitter { + on: ( + event: 'progress', + handler: (progress: ProgressData) => void + ) => Promise; + } } declare const del: { @@ -78,7 +102,7 @@ declare const del: { ( patterns: string | readonly string[], options?: del.Options - ): Promise; + ): Promise & del.ProgressEmitter; }; export = del; diff --git a/index.js b/index.js index e1956b8..61fcc7c 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const isPathCwd = require('is-path-cwd'); const isPathInside = require('is-path-inside'); const rimraf = require('rimraf'); const pMap = require('p-map'); +const {EventEmitter} = require('events'); const rimrafP = promisify(rimraf); @@ -52,7 +53,7 @@ function normalizePatterns(patterns) { return patterns; } -module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { +module.exports = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { options = { expandDirectories: false, onlyFiles: false, @@ -61,30 +62,62 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), ...option ...options }; - patterns = normalizePatterns(patterns); + const progressEmitter = new EventEmitter(); - const files = (await globby(patterns, options)) - .sort((a, b) => b.localeCompare(a)); + const promise = (async () => { + patterns = normalizePatterns(patterns); - const mapper = async file => { - file = path.resolve(cwd, file); + const files = (await globby(patterns, options)) + .sort((a, b) => b.localeCompare(a)); - if (!force) { - safeCheck(file, cwd); - } + if (files.length === 0) { + progressEmitter.emit('progress', { + totalFiles: 0, + deletedFiles: 0, + percent: 1 + }); - if (!dryRun) { - await rimrafP(file, rimrafOptions); + return []; } - return file; - }; + const mapper = async (file, fileIndex) => { + file = path.resolve(cwd, file); - const removedFiles = await pMap(files, mapper, options); + if (!force) { + safeCheck(file, cwd); + } - removedFiles.sort((a, b) => a.localeCompare(b)); + progressEmitter.emit('progress', { + totalFiles: files.length, + deletedFiles: fileIndex, + percent: fileIndex / files.length + }); - return removedFiles; + if (!dryRun) { + await rimrafP(file, rimrafOptions); + } + + return file; + }; + + const removedFiles = await pMap(files, mapper, options); + removedFiles.sort((a, b) => a.localeCompare(b)); + + progressEmitter.emit('progress', { + totalFiles: files.length, + deletedFiles: files.length, + percent: 1 + }); + + return removedFiles; + })(); + + promise.on = (...arguments_) => { + progressEmitter.on(...arguments_); + return promise; + }; + + return promise; }; module.exports.sync = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { diff --git a/index.test-d.ts b/index.test-d.ts index bff5f02..052d996 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,5 @@ import {expectType} from 'tsd'; +import {ProgressEmitter} from './index.d'; import del = require('.'); const paths = [ @@ -7,13 +8,13 @@ const paths = [ ]; // Del -expectType>(del('temp/*.js')); -expectType>(del(paths)); +expectType & ProgressEmitter>(del('temp/*.js')); +expectType & ProgressEmitter>(del(paths)); -expectType>(del(paths, {force: true})); -expectType>(del(paths, {dryRun: true})); -expectType>(del(paths, {concurrency: 20})); -expectType>(del(paths, {cwd: ''})); +expectType & ProgressEmitter>(del(paths, {force: true})); +expectType & ProgressEmitter>(del(paths, {dryRun: true})); +expectType & ProgressEmitter>(del(paths, {concurrency: 20})); +expectType & ProgressEmitter>(del(paths, {cwd: ''})); // Del (sync) expectType(del.sync('tmp/*.js')); diff --git a/readme.md b/readme.md index e071435..2a3bb80 100644 --- a/readme.md +++ b/readme.md @@ -108,6 +108,36 @@ Minimum: `1` Concurrency limit. +## Progress reporting + +### del.on('progress', handler) + +#### handler(progress) + +Type: `Function` + +##### progress + +```js +{ + totalFiles: number, + deletedFiles: number, + percent: number +} +``` + +- `percent` is a value between `0` and `1` + +Note that the `.on()` method is available only right after the initial `del` call, so make sure you add a `handler` before awaiting the promise: + +```js +import del from 'del'; + +await del(patterns).on('progress', progress => { + // … +}); +``` + ## CLI See [del-cli](https://github.com/sindresorhus/del-cli) for a CLI for this module and [trash-cli](https://github.com/sindresorhus/trash-cli) for a safe version that is suitable for running by hand. diff --git a/test.js b/test.js index d5a4fcf..8101818 100644 --- a/test.js +++ b/test.js @@ -349,3 +349,39 @@ test('windows can pass relative paths with "\\" - sync', t => { t.deepEqual(removeFiles, [nestedFile]); }); + +test('report delete progress of non-existent file', async t => { + let report; + + await del('non-existent-directory').on('progress', event => { + report = event; + }); + + t.is(report.totalFiles, 0); + t.is(report.deletedFiles, 0); + t.is(report.percent, 1); +}); + +test('report delete progress of single file', async t => { + let report; + + await del(t.context.tmp, {cwd: __dirname, force: true}).on('progress', event => { + report = event; + }); + + t.is(report.totalFiles, 1); + t.is(report.deletedFiles, 1); + t.is(report.percent, 1); +}); + +test('report delete progress of multiple files', async t => { + let report; + + await del(`${t.context.tmp}/*`, {cwd: __dirname, force: true}).on('progress', event => { + report = event; + }); + + t.is(report.totalFiles, 4); + t.is(report.deletedFiles, 4); + t.is(report.percent, 1); +}); From 556ad5b8b9d24febc1fabf95987fa0c6523ca438 Mon Sep 17 00:00:00 2001 From: jopemachine Date: Thu, 31 Mar 2022 21:06:06 +0900 Subject: [PATCH 2/9] Update test.js --- test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test.js b/test.js index 8101818..27e3541 100644 --- a/test.js +++ b/test.js @@ -377,7 +377,9 @@ test('report delete progress of single file', async t => { test('report delete progress of multiple files', async t => { let report; - await del(`${t.context.tmp}/*`, {cwd: __dirname, force: true}).on('progress', event => { + const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : t.context.tmp; + + await del(sourcePath, {cwd: __dirname, force: true}).on('progress', event => { report = event; }); From e93cc551d51070c5b6dc2b10f517818c465f7433 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Fri, 1 Apr 2022 20:52:19 +0900 Subject: [PATCH 3/9] Update test.js --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index 27e3541..150d970 100644 --- a/test.js +++ b/test.js @@ -377,7 +377,7 @@ test('report delete progress of single file', async t => { test('report delete progress of multiple files', async t => { let report; - const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : t.context.tmp; + const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : `${t.context.tmp}/*`; await del(sourcePath, {cwd: __dirname, force: true}).on('progress', event => { report = event; From 01fc1d84be1712e020b6019f5269cd84ebecd09c Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Fri, 1 Apr 2022 20:55:03 +0900 Subject: [PATCH 4/9] Update test.js --- test.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test.js b/test.js index 150d970..9f6620e 100644 --- a/test.js +++ b/test.js @@ -357,9 +357,11 @@ test('report delete progress of non-existent file', async t => { report = event; }); - t.is(report.totalFiles, 0); - t.is(report.deletedFiles, 0); - t.is(report.percent, 1); + t.deepEqual(report, { + totalFiles: 0, + deletedFiles: 0, + percent: 1, + }); }); test('report delete progress of single file', async t => { @@ -369,9 +371,11 @@ test('report delete progress of single file', async t => { report = event; }); - t.is(report.totalFiles, 1); - t.is(report.deletedFiles, 1); - t.is(report.percent, 1); + t.deepEqual(report, { + totalFiles: 1, + deletedFiles: 1, + percent: 1, + }); }); test('report delete progress of multiple files', async t => { @@ -383,7 +387,9 @@ test('report delete progress of multiple files', async t => { report = event; }); - t.is(report.totalFiles, 4); - t.is(report.deletedFiles, 4); - t.is(report.percent, 1); + t.deepEqual(report, { + totalFiles: 4, + deletedFiles: 4, + percent: 1, + }); }); From 8a755958419907d2a9464ab2fd367e0f461c0605 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Fri, 1 Apr 2022 21:25:08 +0900 Subject: [PATCH 5/9] Change promise attaching to `onProgress` handler --- index.d.ts | 48 +++++++++++++++++------------- index.js | 79 +++++++++++++++++++++---------------------------- index.test-d.ts | 13 ++++---- readme.md | 28 ++++++++---------- test.js | 18 +++++------ 5 files changed, 89 insertions(+), 97 deletions(-) diff --git a/index.d.ts b/index.d.ts index fc20448..3bbcf88 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,22 @@ import {GlobbyOptions} from 'globby'; declare namespace del { + interface ProgressData { + /** + Deleted file count. + */ + deletedFiles: number; + + /** + Overall file count. + */ + totalFiles: number; + + /** + Completed percentage. A value between `0` and `1`. + */ + percent: number; + } interface Options extends GlobbyOptions { /** Allow deleting the current working directory and outside. @@ -33,30 +49,22 @@ declare namespace del { @default Infinity */ readonly concurrency?: number; - } - interface ProgressData { /** - Deleted file count. - */ - deletedFiles: number; + Callback function for progress reporting. - /** - Overall file count. - */ - totalFiles: number; + Called before each file is deleted. - /** - Completed percentage. A value between `0` and `1`. - */ - percent: number; - } + @example + ```js + import del from 'del'; - interface ProgressEmitter { - on: ( - event: 'progress', - handler: (progress: ProgressData) => void - ) => Promise; + await del(patterns, {onProgress: (progress) => { + // … + }}); + ``` + */ + readonly onProgress?: (progress: ProgressData) => void; } } @@ -102,7 +110,7 @@ declare const del: { ( patterns: string | readonly string[], options?: del.Options - ): Promise & del.ProgressEmitter; + ): Promise; }; export = del; diff --git a/index.js b/index.js index 61fcc7c..07d133f 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ const isPathCwd = require('is-path-cwd'); const isPathInside = require('is-path-inside'); const rimraf = require('rimraf'); const pMap = require('p-map'); -const {EventEmitter} = require('events'); const rimrafP = promisify(rimraf); @@ -53,7 +52,7 @@ function normalizePatterns(patterns) { return patterns; } -module.exports = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { +module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress = () => {}, ...options} = {}) => { options = { expandDirectories: false, onlyFiles: false, @@ -62,62 +61,50 @@ module.exports = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = { ...options }; - const progressEmitter = new EventEmitter(); + patterns = normalizePatterns(patterns); - const promise = (async () => { - patterns = normalizePatterns(patterns); + const files = (await globby(patterns, options)) + .sort((a, b) => b.localeCompare(a)); - const files = (await globby(patterns, options)) - .sort((a, b) => b.localeCompare(a)); + if (files.length === 0) { + onProgress({ + totalFiles: 0, + deletedFiles: 0, + percent: 1 + }); + } - if (files.length === 0) { - progressEmitter.emit('progress', { - totalFiles: 0, - deletedFiles: 0, - percent: 1 - }); + const mapper = async (file, fileIndex) => { + file = path.resolve(cwd, file); - return []; + if (!force) { + safeCheck(file, cwd); } - const mapper = async (file, fileIndex) => { - file = path.resolve(cwd, file); - - if (!force) { - safeCheck(file, cwd); - } - - progressEmitter.emit('progress', { - totalFiles: files.length, - deletedFiles: fileIndex, - percent: fileIndex / files.length - }); - - if (!dryRun) { - await rimrafP(file, rimrafOptions); - } - - return file; - }; - - const removedFiles = await pMap(files, mapper, options); - removedFiles.sort((a, b) => a.localeCompare(b)); - - progressEmitter.emit('progress', { + onProgress({ totalFiles: files.length, - deletedFiles: files.length, - percent: 1 + deletedFiles: fileIndex, + percent: fileIndex / files.length }); - return removedFiles; - })(); + if (!dryRun) { + await rimrafP(file, rimrafOptions); + } - promise.on = (...arguments_) => { - progressEmitter.on(...arguments_); - return promise; + return file; }; - return promise; + const removedFiles = await pMap(files, mapper, options); + + onProgress({ + totalFiles: files.length, + deletedFiles: files.length, + percent: 1 + }); + + removedFiles.sort((a, b) => a.localeCompare(b)); + + return removedFiles; }; module.exports.sync = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => { diff --git a/index.test-d.ts b/index.test-d.ts index 052d996..bff5f02 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,4 @@ import {expectType} from 'tsd'; -import {ProgressEmitter} from './index.d'; import del = require('.'); const paths = [ @@ -8,13 +7,13 @@ const paths = [ ]; // Del -expectType & ProgressEmitter>(del('temp/*.js')); -expectType & ProgressEmitter>(del(paths)); +expectType>(del('temp/*.js')); +expectType>(del(paths)); -expectType & ProgressEmitter>(del(paths, {force: true})); -expectType & ProgressEmitter>(del(paths, {dryRun: true})); -expectType & ProgressEmitter>(del(paths, {concurrency: 20})); -expectType & ProgressEmitter>(del(paths, {cwd: ''})); +expectType>(del(paths, {force: true})); +expectType>(del(paths, {dryRun: true})); +expectType>(del(paths, {concurrency: 20})); +expectType>(del(paths, {cwd: ''})); // Del (sync) expectType(del.sync('tmp/*.js')); diff --git a/readme.md b/readme.md index 2a3bb80..eaa61fd 100644 --- a/readme.md +++ b/readme.md @@ -108,15 +108,23 @@ Minimum: `1` Concurrency limit. -## Progress reporting +##### onProgress -### del.on('progress', handler) +Type: `(progress: ProgressData) => void` -#### handler(progress) +Callback function for progress reporting. -Type: `Function` +Called before each file is deleted. -##### progress +```js +import del from 'del'; + +await del(patterns, {onProgress: (progress) => { + // … +}}); +``` + +###### ProgressData ```js { @@ -128,16 +136,6 @@ Type: `Function` - `percent` is a value between `0` and `1` -Note that the `.on()` method is available only right after the initial `del` call, so make sure you add a `handler` before awaiting the promise: - -```js -import del from 'del'; - -await del(patterns).on('progress', progress => { - // … -}); -``` - ## CLI See [del-cli](https://github.com/sindresorhus/del-cli) for a CLI for this module and [trash-cli](https://github.com/sindresorhus/trash-cli) for a safe version that is suitable for running by hand. diff --git a/test.js b/test.js index 9f6620e..93ae360 100644 --- a/test.js +++ b/test.js @@ -353,28 +353,28 @@ test('windows can pass relative paths with "\\" - sync', t => { test('report delete progress of non-existent file', async t => { let report; - await del('non-existent-directory').on('progress', event => { + await del('non-existent-directory', {onProgress: event => { report = event; - }); + }}); t.deepEqual(report, { totalFiles: 0, deletedFiles: 0, - percent: 1, + percent: 1 }); }); test('report delete progress of single file', async t => { let report; - await del(t.context.tmp, {cwd: __dirname, force: true}).on('progress', event => { + await del(t.context.tmp, {cwd: __dirname, force: true, onProgress: event => { report = event; - }); + }}); t.deepEqual(report, { totalFiles: 1, deletedFiles: 1, - percent: 1, + percent: 1 }); }); @@ -383,13 +383,13 @@ test('report delete progress of multiple files', async t => { const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : `${t.context.tmp}/*`; - await del(sourcePath, {cwd: __dirname, force: true}).on('progress', event => { + await del(sourcePath, {cwd: __dirname, force: true, onProgress: event => { report = event; - }); + }}); t.deepEqual(report, { totalFiles: 4, deletedFiles: 4, - percent: 1, + percent: 1 }); }); From a44967f6cac03474d83823e56ae91c596b48f809 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Tue, 19 Apr 2022 10:12:45 +0900 Subject: [PATCH 6/9] Reflect feedbacks --- index.d.ts | 7 ++++--- index.js | 8 ++++---- readme.md | 7 +++---- test.js | 16 ++++++++++------ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3bbcf88..9f45a35 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,12 +3,12 @@ import {GlobbyOptions} from 'globby'; declare namespace del { interface ProgressData { /** - Deleted file count. + Deleted files and directories count. */ deletedFiles: number; /** - Overall file count. + Total files and directories count. */ totalFiles: number; @@ -17,6 +17,7 @@ declare namespace del { */ percent: number; } + interface Options extends GlobbyOptions { /** Allow deleting the current working directory and outside. @@ -56,7 +57,7 @@ declare namespace del { Called before each file is deleted. @example - ```js + ``` import del from 'del'; await del(patterns, {onProgress: (progress) => { diff --git a/index.js b/index.js index 07d133f..c490694 100644 --- a/index.js +++ b/index.js @@ -81,16 +81,16 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres safeCheck(file, cwd); } + if (!dryRun) { + await rimrafP(file, rimrafOptions); + } + onProgress({ totalFiles: files.length, deletedFiles: fileIndex, percent: fileIndex / files.length }); - if (!dryRun) { - await rimrafP(file, rimrafOptions); - } - return file; }; diff --git a/readme.md b/readme.md index eaa61fd..3d59013 100644 --- a/readme.md +++ b/readme.md @@ -112,14 +112,13 @@ Concurrency limit. Type: `(progress: ProgressData) => void` -Callback function for progress reporting. - -Called before each file is deleted. +Called after each file is deleted. ```js import del from 'del'; -await del(patterns, {onProgress: (progress) => { +await del(patterns, { + onProgress: progress => { // … }}); ``` diff --git a/test.js b/test.js index 93ae360..fa71d18 100644 --- a/test.js +++ b/test.js @@ -350,7 +350,7 @@ test('windows can pass relative paths with "\\" - sync', t => { t.deepEqual(removeFiles, [nestedFile]); }); -test('report delete progress of non-existent file', async t => { +test('onProgress option - progress of non-existent file', async t => { let report; await del('non-existent-directory', {onProgress: event => { @@ -364,7 +364,7 @@ test('report delete progress of non-existent file', async t => { }); }); -test('report delete progress of single file', async t => { +test('onProgress option - progress of single file', async t => { let report; await del(t.context.tmp, {cwd: __dirname, force: true, onProgress: event => { @@ -378,14 +378,18 @@ test('report delete progress of single file', async t => { }); }); -test('report delete progress of multiple files', async t => { +test('onProgress option - progress of multiple files', async t => { let report; const sourcePath = process.platform === 'win32' ? path.resolve(`${t.context.tmp}/*`).replace(/\\/g, '/') : `${t.context.tmp}/*`; - await del(sourcePath, {cwd: __dirname, force: true, onProgress: event => { - report = event; - }}); + await del(sourcePath, { + cwd: __dirname, + force: true, + onProgress: event => { + report = event; + } + }); t.deepEqual(report, { totalFiles: 4, From 909fe599dfbcce795c566918596b435b72f8266d Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Fri, 6 May 2022 17:58:34 +0900 Subject: [PATCH 7/9] Reflect feedbacks --- index.d.ts | 4 ++-- index.js | 12 ++++++------ test.js | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9f45a35..d8f0cd8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -5,12 +5,12 @@ declare namespace del { /** Deleted files and directories count. */ - deletedFiles: number; + deletedCount: number; /** Total files and directories count. */ - totalFiles: number; + totalCount: number; /** Completed percentage. A value between `0` and `1`. diff --git a/index.js b/index.js index c490694..735aabe 100644 --- a/index.js +++ b/index.js @@ -68,8 +68,8 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres if (files.length === 0) { onProgress({ - totalFiles: 0, - deletedFiles: 0, + totalCount: 0, + deletedCount: 0, percent: 1 }); } @@ -86,8 +86,8 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres } onProgress({ - totalFiles: files.length, - deletedFiles: fileIndex, + totalCount: files.length, + deletedCount: fileIndex, percent: fileIndex / files.length }); @@ -97,8 +97,8 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres const removedFiles = await pMap(files, mapper, options); onProgress({ - totalFiles: files.length, - deletedFiles: files.length, + totalCount: files.length, + deletedCount: files.length, percent: 1 }); diff --git a/test.js b/test.js index fa71d18..b7aa11c 100644 --- a/test.js +++ b/test.js @@ -358,8 +358,8 @@ test('onProgress option - progress of non-existent file', async t => { }}); t.deepEqual(report, { - totalFiles: 0, - deletedFiles: 0, + totalCount: 0, + deletedCount: 0, percent: 1 }); }); @@ -372,8 +372,8 @@ test('onProgress option - progress of single file', async t => { }}); t.deepEqual(report, { - totalFiles: 1, - deletedFiles: 1, + totalCount: 1, + deletedCount: 1, percent: 1 }); }); @@ -392,8 +392,8 @@ test('onProgress option - progress of multiple files', async t => { }); t.deepEqual(report, { - totalFiles: 4, - deletedFiles: 4, + totalCount: 4, + deletedCount: 4, percent: 1 }); }); From 8131b3fe9e2b8c2dfeaffff0b7fef1d6c81aaa49 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Mon, 9 May 2022 09:10:01 +0900 Subject: [PATCH 8/9] Reflect feedback --- index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index d8f0cd8..e81c33b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -52,9 +52,7 @@ declare namespace del { readonly concurrency?: number; /** - Callback function for progress reporting. - - Called before each file is deleted. + Called after each file is deleted. @example ``` From fffc5acb4d814303a2363071e57030ef6c5076d2 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Mon, 16 May 2022 08:31:47 +0900 Subject: [PATCH 9/9] Reflect Feedback --- index.d.ts | 5 +++-- readme.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index e81c33b..25608eb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -52,13 +52,14 @@ declare namespace del { readonly concurrency?: number; /** - Called after each file is deleted. + Called after each file or directory is deleted. @example ``` import del from 'del'; - await del(patterns, {onProgress: (progress) => { + await del(patterns, { + onProgress: progress => { // … }}); ``` diff --git a/readme.md b/readme.md index 3d59013..bfd47f4 100644 --- a/readme.md +++ b/readme.md @@ -112,7 +112,7 @@ Concurrency limit. Type: `(progress: ProgressData) => void` -Called after each file is deleted. +Called after each file or directory is deleted. ```js import del from 'del';