Comparing version 3.3.5 to 3.4.0
// Generated by CoffeeScript 1.12.7 | ||
(function() { | ||
var stopwatch, timeOperation, timeOperationAsync; | ||
var stopwatch, timeOperationAsync, timeOperationPromised, timeOperationSync; | ||
stopwatch = require('./stopwatch'); | ||
timeOperation = function(operation) { | ||
timeOperationSync = function(operation) { | ||
var watch; | ||
@@ -16,16 +16,48 @@ watch = stopwatch["new"]().start(); | ||
var next, watch; | ||
watch = stopwatch["new"]().start(); | ||
next = function() { | ||
var duration; | ||
duration = watch.stop().duration(); | ||
return callback(duration); | ||
}; | ||
return operation(next); | ||
watch = stopwatch["new"](); | ||
if (typeof callback === 'function') { | ||
next = function() { | ||
return callback(watch.stop().duration()); | ||
}; | ||
watch.start(); | ||
operation(next); | ||
return void 0; | ||
} else { | ||
return new Promise(function(resolve, reject) { | ||
next = function(error) { | ||
if (error != null) { | ||
return reject(error); | ||
} else { | ||
return resolve(watch.stop().duration()); | ||
} | ||
}; | ||
watch.start(); | ||
return operation(next); | ||
}); | ||
} | ||
}; | ||
timeOperationPromised = function(operation, callback) { | ||
var watch; | ||
watch = stopwatch["new"](); | ||
if (typeof callback === 'function') { | ||
watch.start(); | ||
operation().then(function() { | ||
return callback(watch.stop().duration()); | ||
}); | ||
return void 0; | ||
} else { | ||
watch.start(); | ||
return operation().then(function() { | ||
return watch.stop().duration(); | ||
}); | ||
} | ||
}; | ||
module.exports = { | ||
time: timeOperation, | ||
timeAsync: timeOperationAsync | ||
time: timeOperationSync, | ||
timeAsync: timeOperationAsync, | ||
timePromised: timeOperationPromised | ||
}; | ||
}).call(this); |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "3.3.5", | ||
"version": "3.4.0", | ||
"author": "Joel Edwards (https://github.com/joeledwards)", | ||
@@ -32,2 +32,3 @@ "contributors": [ | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"coffee-script": "^1.12.7", | ||
@@ -34,0 +35,0 @@ "mocha": "^2.3.4", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15427
253
4