You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@pacote/memoize

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pacote/memoize - npm Package Compare versions

Comparing version

to
2.0.2

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

## [2.0.2](https://github.com/PacoteJS/pacote/compare/@pacote/memoize@2.0.1...@pacote/memoize@2.0.2) (2023-06-15)
### Performance Improvements
- ⚡️ use Map for memoize cache ([407ea26](https://github.com/PacoteJS/pacote/commit/407ea2666283d23255a82b5563c64cccf1b31805))
## [2.0.1](https://github.com/PacoteJS/pacote/compare/@pacote/memoize@2.0.0...@pacote/memoize@2.0.1) (2023-04-22)

@@ -8,0 +14,0 @@

11

lib/cjs/index.js

@@ -5,9 +5,7 @@ "use strict";

function createCache() {
var cache = {};
var cache = new Map();
return {
has: function (key) { return Object.hasOwnProperty.call(cache, key); },
get: function (key) { return cache[key]; },
set: function (key, value) {
cache[key] = value;
},
has: function (key) { return cache.has(key); },
get: function (key) { return cache.get(key); },
set: function (key, value) { return cache.set(key, value); },
};

@@ -26,2 +24,3 @@ }

}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return cache.get(key);

@@ -28,0 +27,0 @@ };

function createCache() {
const cache = {};
const cache = new Map();
return {
has: (key) => Object.hasOwnProperty.call(cache, key),
get: (key) => cache[key],
set: (key, value) => {
cache[key] = value;
},
has: (key) => cache.has(key),
get: (key) => cache.get(key),
set: (key, value) => cache.set(key, value),
};

@@ -18,2 +16,3 @@ }

}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return cache.get(key);

@@ -20,0 +19,0 @@ };

{
"name": "@pacote/memoize",
"description": "Memoization function.",
"version": "2.0.1",
"version": "2.0.2",
"sideEffects": false,

@@ -37,3 +37,3 @@ "license": "MIT",

},
"gitHead": "d0e1f3f1f0b32a28cf51f226dd2c9d247503b4ee"
"gitHead": "fbaede424db38eb61497d56835a012e23ab774f2"
}
type Fn<A extends any[], R> = (...args: A) => R
interface Cache<R> {
[key: string]: R
}
function createCache<R>() {
const cache: Cache<R> = {}
const cache = new Map<string, R>()
return {
has: (key: string) => Object.hasOwnProperty.call(cache, key),
get: (key: string) => cache[key],
set: (key: string, value: R) => {
cache[key] = value
},
has: (key: string) => cache.has(key),
get: (key: string) => cache.get(key),
set: (key: string, value: R) => cache.set(key, value),
}

@@ -34,4 +26,5 @@ }

return cache.get(key)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return cache.get(key)!
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet