New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

utilsac

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utilsac - npm Package Compare versions

Comparing version 10.5.5 to 11.0.0

11

changelog.md
# Changelog
## 11.0.0
remove
* createCustomRound
* createThrottledUsingTimeout
* arrayWithResults in favor of Array.from({length: times}, aFunction)
browse this commit dd5fbb65b377fc4174d9444d663debfdb3f1b628
or use 10.5.6 to keep using
## 10.5.0

@@ -4,0 +15,0 @@

2

package.json
{
"name": "utilsac",
"version": "10.5.5",
"version": "11.0.0",
"description": "Utility functions",

@@ -5,0 +5,0 @@ "type": "module",

@@ -16,4 +16,2 @@ # Utility functions

throttledWithLast,
createCustomRound,
arrayWithResults,
chainPromises,

@@ -20,0 +18,0 @@ chainRequestAnimationFrame,

@@ -5,5 +5,2 @@ export {

throttledWithLast,
createThrottledUsingTimeout,
createCustomRound,
arrayWithResults,
chainPromises,

@@ -90,56 +87,2 @@ chainRequestAnimationFrame,

const createThrottledUsingTimeout = function (functionToThrottle, minimumTimeSpace = 150) {
/* creates a function that is throttled,
calling it once will execute it immediately
calling it very often during a period less than minimumTimeSpace will only execute it once
the returned function always return undefined */
let ready = true;
const makeReady = function () {
ready = true;
};
return function (...args) {
if (!ready) {
return;
}
ready = false;
functionToThrottle(...args);
setTimeout(makeReady, minimumTimeSpace);
};
};
const createCustomRound = function (precision) {
/* creates a function similar to Math.round (has precision of 1)
with any precision, example:
const roundStep02 = createCustomRound(0.2);
roundStep02(0.6125897); --> 0.6000000000000001 (rounded down)
roundStep02(0.12); --> 0.2 (rounded up)
roundStep02(2.4); --> 2.4000000000000004 (almost not rounded)
roundStep02(5); --> 5 (already rounded)
warning: can have small errors due to fixed precision floats */
const halfPrecision = precision / 2;
return function (anyNumber) {
const rest = anyNumber % precision;
if (rest === 0) {
return anyNumber;
}
if (rest > halfPrecision) {
return anyNumber + (precision - rest);
}
return anyNumber - rest;
};
};
const arrayWithResults = function (aFunction, times) {
/* [].fill is for static values only
alternative , return Array.from({length: times}, aFunction);
same if aFunction ignores its second argument */
const array = [];
for (let i = 0; i < times; i += 1) {
array.push(aFunction());
}
return array;
};
const doNTimes = function (task, times) {

@@ -146,0 +89,0 @@ for (let i = 0; i < times; i += 1) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc