@zlikemario/helper 0.0.3 → 0.0.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.
- package/dist/decorator.cjs +1 -0
- package/dist/decorator.js +20 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./utils.cjs");function y(i=0,u=(...o)=>o[0],l=!1){return function(o,d,e){const f=e.value,t=new Map;let a=Date.now();const r=()=>i>0&&a<Date.now();return e.value=async function(...c){const n=u(...c);if(!t.get(n)||r()){a=Date.now()+i;const s=await f.apply(this,c);(l||!m.isUndefined(s))&&t.set(n,s)}return t.get(n)},e}}exports.memoize=y;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isUndefined as r } from "./utils.js";
|
|
2
|
+
function p(a = 0, s = (...o) => o[0], u = !1) {
|
|
3
|
+
return function(o, w, e) {
|
|
4
|
+
const l = e.value, n = /* @__PURE__ */ new Map();
|
|
5
|
+
let i = Date.now();
|
|
6
|
+
const m = () => a > 0 && i < Date.now();
|
|
7
|
+
return e.value = async function(...c) {
|
|
8
|
+
const t = s(...c);
|
|
9
|
+
if (!n.get(t) || m()) {
|
|
10
|
+
i = Date.now() + a;
|
|
11
|
+
const f = await l.apply(this, c);
|
|
12
|
+
(u || !r(f)) && n.set(t, f);
|
|
13
|
+
}
|
|
14
|
+
return n.get(t);
|
|
15
|
+
}, e;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
p as memoize
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlikemario/helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A utility library with number operations and common helper functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utility",
|
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
"types": "./dist/utils.d.ts",
|
|
60
60
|
"import": "./dist/utils.js",
|
|
61
61
|
"require": "./dist/utils.cjs"
|
|
62
|
+
},
|
|
63
|
+
"./decorator": {
|
|
64
|
+
"types": "./dist/decorator.d.ts",
|
|
65
|
+
"import": "./dist/decorator.js",
|
|
66
|
+
"require": "./dist/decorator.cjs"
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
"packageManager": "yarn@4.9.4+sha512.7b1cb0b62abba6a537b3a2ce00811a843bea02bcf53138581a6ae5b1bf563f734872bd47de49ce32a9ca9dcaff995aa789577ffb16811da7c603dcf69e73750b",
|