@rickard.antonsson/ts-utility 2.2.3 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.memoize = memoize;
|
|
4
4
|
function memoize(fn) {
|
|
5
|
-
const
|
|
5
|
+
const returns = new Map();
|
|
6
6
|
return (...args) => {
|
|
7
|
-
var _a;
|
|
8
7
|
const key = JSON.stringify(args);
|
|
9
|
-
|
|
8
|
+
if (returns.has(key)) {
|
|
9
|
+
//console.log('used cache');
|
|
10
|
+
return returns.get(key);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const result = fn(...args);
|
|
14
|
+
returns.set(key, result);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
10
17
|
};
|
|
11
18
|
}
|
|
12
19
|
//# sourceMappingURL=memoize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../../src/functions/time/memoize.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../../src/functions/time/memoize.ts"],"names":[],"mappings":";;AAEA,0BAaC;AAbD,SAAgB,OAAO,CAAmB,EAAM;IAC9C,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAClD,OAAO,CAAC,GAAG,IAAoB,EAAkB,EAAE;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,4BAA4B;YAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rickard.antonsson/ts-utility",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "My favorite small helper functions",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
],
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"keywords": [],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"lint": "gts lint",
|
|
15
|
+
"clean": "gts clean",
|
|
16
|
+
"compile": "tsc",
|
|
17
|
+
"fix": "gts fix",
|
|
18
|
+
"prepare": "pnpm run compile",
|
|
19
|
+
"pretest": "pnpm run compile",
|
|
20
|
+
"posttest": "pnpm run lint"
|
|
21
|
+
},
|
|
12
22
|
"devDependencies": {
|
|
13
23
|
"@babel/core": "^7.16.0",
|
|
14
24
|
"@babel/preset-env": "^7.23.3",
|
|
@@ -21,17 +31,5 @@
|
|
|
21
31
|
"gts": "^3.1.0",
|
|
22
32
|
"jest": "^27.4.3",
|
|
23
33
|
"typescript": "~5.5.3"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@rickard.antonsson/ts-utility": "file:"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"test": "jest",
|
|
30
|
-
"lint": "gts lint",
|
|
31
|
-
"clean": "gts clean",
|
|
32
|
-
"compile": "tsc",
|
|
33
|
-
"fix": "gts fix",
|
|
34
|
-
"pretest": "pnpm run compile",
|
|
35
|
-
"posttest": "pnpm run lint"
|
|
36
34
|
}
|
|
37
|
-
}
|
|
35
|
+
}
|