Comparing version 4.1.0 to 4.2.0
{ | ||
"name": "utilsac", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "tools mostly", | ||
@@ -5,0 +5,0 @@ "main": "files.js", |
@@ -18,2 +18,3 @@ # Utilities and random js files | ||
export { | ||
createThrottledFunction, | ||
createCustomRound, | ||
@@ -20,0 +21,0 @@ fillArrayWithFunctionResult, |
export { | ||
createThrottledFunction, | ||
createCustomRound, | ||
@@ -11,2 +12,22 @@ fillArrayWithFunctionResult, | ||
const createThrottledFunction = function (functionToThrottle, minimumTimeSpace) { | ||
/* creates a function that is throttled, | ||
calling it very often during a period less than minimumTimeSpace will only execute it once | ||
an alternative implementation could use Date.now() , this means less performance | ||
but would work for throttling inside a single tick | ||
*/ | ||
let ready = true; | ||
const makeReady = function() { | ||
ready = true; | ||
}; | ||
return function(...args) { | ||
if (ready) { | ||
ready = false; | ||
functionToThrottle(...args); | ||
timeout = setTimeout(makeReady, minimumTimeSpace); | ||
} | ||
}; | ||
}; | ||
const createCustomRound = function (precision) { | ||
@@ -13,0 +34,0 @@ /* creates a function similar to Math.round (has precision of 1) |
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
7323
199
27