UNPKG

@mightyplow/jslib

Version:

js helpers library

22 lines (20 loc) 485 B
var i = 0; /** * Takes a function and logs the time it takes on the console. * * @memberOf function * @function * @param label * @param fn */ var measureTime = function measureTime() { var label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : i++; var fn = arguments[1]; return function () { console.time(label); var result = fn.apply(undefined, arguments); console.timeEnd(label); return result; }; }; export default measureTime;