Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@mightyplow/jslib

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mightyplow/jslib - npm Package Compare versions

Comparing version
0.17.0
to
0.18.0
+27
function/measureTime.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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;
};
};
exports.default = measureTime;
+7
-8

@@ -23,7 +23,8 @@ "use strict";

var timer = null;
var abortTimer = function abortTimer() {
var abort = function abort() {
return clearTimeout(timer);
};
var debouncedFunction = function debouncedFunction() {
// extend function with abort method
return Object.assign(function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

@@ -33,11 +34,9 @@ args[_key] = arguments[_key];

abortTimer();
abort();
timer = setTimeout(function () {
return fn.apply(undefined, args);
}, timeout);
};
debouncedFunction.abort = abortTimer;
return debouncedFunction;
}, {
abort: abort
});
};

@@ -88,2 +88,11 @@ 'use strict';

var _measureTime = require('./measureTime');
Object.defineProperty(exports, 'measureTime', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_measureTime).default;
}
});
var _noop = require('./noop');

@@ -90,0 +99,0 @@

@@ -108,2 +108,8 @@ 'use strict';

});
Object.defineProperty(exports, 'measureTime', {
enumerable: true,
get: function get() {
return _function.measureTime;
}
});
Object.defineProperty(exports, 'memoize', {

@@ -110,0 +116,0 @@ enumerable: true,

{
"name": "@mightyplow/jslib",
"version": "0.17.0",
"version": "0.18.0",
"description": "js helpers library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -125,2 +125,3 @@ ## Objects

* [.indentity(arg)](#function.indentity)
* [.measureTime(label, fn)](#function.measureTime)
* [.memoize(fn, [timeout])](#function.memoize) ⇒ [<code>function</code>](#function)

@@ -205,2 +206,14 @@ * [.module.exports()](#function.module.exports)

<a name="function.measureTime"></a>
### function.measureTime(label, fn)
Takes a function and logs the time it takes on the console.
**Kind**: static method of [<code>function</code>](#function)
| Param |
| --- |
| label |
| fn |
<a name="function.memoize"></a>

@@ -207,0 +220,0 @@