@zlikemario/helper 0.0.8 → 0.0.9

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./utils.cjs");function m(s=0,i=(...a)=>a[0],c=!1){return function(a,r,o){const d=o.value,e=new Map;let f=Date.now();const g=Symbol(String(r)),h=()=>s>0&&f<Date.now();return o.value=function(...l){const n=(typeof i=="function"?i(...l):i)??g;if(!e.get(n)||h()){f=Date.now()+s;const t=d.apply(this,l);t instanceof Promise?(e.set(n,t),t.then(M=>{!c&&u.isUndefined(M)&&e.delete(n)})):(c||!u.isUndefined(t))&&e.set(n,t)}return e.get(n)},o}}exports.Memoize=m;
@@ -0,0 +1,22 @@
1
+ import { isUndefined as r } from "./utils.js";
2
+ function g(f = 0, o = (...c) => c[0], a = !1) {
3
+ return function(c, u, i) {
4
+ const h = i.value, e = /* @__PURE__ */ new Map();
5
+ let s = Date.now();
6
+ const d = Symbol(String(u)), m = () => f > 0 && s < Date.now();
7
+ return i.value = function(...l) {
8
+ const n = (typeof o == "function" ? o(...l) : o) ?? d;
9
+ if (!e.get(n) || m()) {
10
+ s = Date.now() + f;
11
+ const t = h.apply(this, l);
12
+ t instanceof Promise ? (e.set(n, t), t.then((w) => {
13
+ !a && r(w) && e.delete(n);
14
+ })) : (a || !r(t)) && e.set(n, t);
15
+ }
16
+ return e.get(n);
17
+ }, i;
18
+ };
19
+ }
20
+ export {
21
+ g as Memoize
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlikemario/helper",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A utility library with number operations and common helper functions",
5
5
  "keywords": [
6
6
  "utility",
@@ -63,6 +63,11 @@
63
63
  "types": "./dist/decorator.d.ts",
64
64
  "import": "./dist/decorator.js",
65
65
  "require": "./dist/decorator.cjs"
66
+ },
67
+ "./decorator-old": {
68
+ "types": "./dist/decorator-old.d.ts",
69
+ "import": "./dist/decorator-old.js",
70
+ "require": "./dist/decorator-old.cjs"
66
71
  }
67
72
  },
68
73
  "packageManager": "yarn@4.9.4+sha512.7b1cb0b62abba6a537b3a2ce00811a843bea02bcf53138581a6ae5b1bf563f734872bd47de49ce32a9ca9dcaff995aa789577ffb16811da7c603dcf69e73750b",