petty-cache 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +3 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
- const util = require('util');
2
-
3
1
  const async = require('async');
4
2
  const lock = require('lock').Lock();
5
3
  const memoryCache = require('memory-cache');
@@ -336,7 +334,8 @@ function PettyCache() {
336
334
  }
337
335
 
338
336
  // Execute the specified function and place the results in cache before returning the data
339
- if (util.types.isAsyncFunction(func)) {
337
+ if (func.length === 0) {
338
+ // If the function doesn't have any arguments, there wasn't a callback provided
340
339
  try {
341
340
  const data = await func();
342
341
 
@@ -347,6 +346,7 @@ function PettyCache() {
347
346
  callback(err);
348
347
  }
349
348
  } else {
349
+ // If the function has arguments, there was a callback provided
350
350
  func(function(err, data) {
351
351
  if (err) {
352
352
  return callback(err);
package/package.json CHANGED
@@ -30,5 +30,5 @@
30
30
  "type": "git",
31
31
  "url": "https://github.com/mediocre/petty-cache.git"
32
32
  },
33
- "version": "3.3.0"
33
+ "version": "3.3.1"
34
34
  }