From 76ae1d149263758af2a48384f3e48d8ccf34bc52 Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Sat, 13 Jun 2020 09:14:37 +0200 Subject: [PATCH 1/3] Add isFunction() helper --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index fa768fb..d280d54 100644 --- a/index.js +++ b/index.js @@ -44,14 +44,14 @@ function prep(fs, Promise) { return hashElementPromise(basename, dir, options, true); }) .then(result => { - if (typeof callback === 'function') { + if (isFunction(callback)) { return callback(undefined, result); } else { return result; } }) .catch(reason => { - if (typeof callback === 'function') { + if (isFunction(callback)) { return callback(reason); } else { throw reason; @@ -268,6 +268,10 @@ function parseParameters(args) { return Promise.resolve(log.params({ basename, dir, options })); } +function isFunction(any) { + return typeof any === 'function'; +} + function isString(str) { return typeof str === 'string' || str instanceof String; } @@ -281,7 +285,7 @@ function notUndefined(obj) { } function reduceGlobPatterns(globs) { - if (typeof globs === 'function') { + if (isFunction(globs)) { return globs; } else if (!globs || !Array.isArray(globs) || globs.length === 0) { From 1bc7ddfa92de616f1027a7c0fceebb2e374bf2b0 Mon Sep 17 00:00:00 2001 From: bernard ng <31113941+bernard-ng@users.noreply.github.com> Date: Wed, 2 Sep 2020 13:11:27 +0200 Subject: [PATCH 2/3] Fix comma position in hashfolder.toString (#74) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d280d54..a38ac43 100644 --- a/index.js +++ b/index.js @@ -204,7 +204,7 @@ function prep(fs, Promise) { }; HashedFolder.prototype.toString = function (padding = '') { - const first = `${padding}{ name: '${this.name}', hash: '${this.hash},'\n`; + const first = `${padding}{ name: '${this.name}', hash: '${this.hash}',\n`; padding += ' '; return `${first}${padding}children: ${this.childrenToString(padding)}}`; From 65f2cebc3c14bdbf5d7484b3993ac680b914f2fd Mon Sep 17 00:00:00 2001 From: Marc Walter Date: Wed, 2 Sep 2020 13:28:14 +0200 Subject: [PATCH 3/3] 3.3.3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24ffeb6..e2f5986 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "folder-hash", - "version": "3.3.2", + "version": "3.3.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7cd8e5a..56bd82c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "folder-hash", - "version": "3.3.2", + "version": "3.3.3", "description": "Create a hash checksum over a folder and its content - its children and their content", "main": "index.js", "bin": {