Skip to content

Commit

Permalink
Add isFunction() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
marc136 committed Jun 13, 2020
1 parent 5a2c1af commit 76ae1d1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down

0 comments on commit 76ae1d1

Please sign in to comment.