Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

utilsac

Package Overview
Dependencies
Maintainers
1
Versions
73
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 5.4.1 to 5.5.0

2

package.json
{
"name": "utilsac",
"version": "5.4.1",
"version": "5.5.0",
"description": "tools mostly",

@@ -5,0 +5,0 @@ "main": "files.js",

@@ -36,3 +36,4 @@ # Utilities and random js files

timeCallback,
timePromise
timePromise,
memoizeAsStrings
} from "path.../utility.js";

@@ -39,0 +40,0 @@ ```

@@ -10,3 +10,4 @@ export {

timeCallback,
timePromise
timePromise,
memoizeAsStrings
};

@@ -173,1 +174,27 @@

};
const memoizeAsStrings = function (functionToMemoize) {
/*
todo explain better the limitations and benefits of this approach
joins together the args as strings to compare
false possible cache hits when "-" is inside the string
*/
const separator = "-";
const previousResults = {};
return function (...args) {
const argumentsAsStrings = args.map(String).join(separator);
/*
without .map(String) works but undefined and null become empty strings
const argumentsAsStrings = args.join(separator);
*/
if (Object.prototype.hasOwnProperty.call(previousResults, argumentsAsStrings)) {
// cache hit
return previousResults[argumentsAsStrings];
}
// not yet in cache
const result = functionToMemoize(...args);
// add it for later
previousResults[argumentsAsStrings] = result;
return result;
};
};
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