@zlikemario/helper 0.0.6 → 0.0.7

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./utils.cjs");function d(o=0,e=(...t)=>t[0],r=!1){return function(t){const n=new Map;let c=Date.now();const f=()=>o>0&&c<Date.now();async function u(...a){const i=typeof e=="function"?e(...a):e;if(!n.get(i)||f()){c=Date.now()+o;const s=await t.apply(this,a);(r||!l.isUndefined(s))&&n.set(i,s)}return n.get(i)}return u}}exports.Memoize=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./utils.cjs");function p(s=0,i=(...o)=>o[0],c=!1){return function(o){const e=new Map;let f=Date.now();const l=()=>s>0&&f<Date.now();function d(...r){const t=typeof i=="function"?i(...r):i;if(!e.get(t)||l()){f=Date.now()+s;const n=o.apply(this,r);n instanceof Promise?(e.set(t,n),n.then(u=>{!c&&a.isUndefined(u)&&e.delete(t)})):(c||!a.isUndefined(n))&&e.set(t,n)}return e.get(t)}return d}}exports.Memoize=p;
@@ -1 +1 @@
1
- export declare function Memoize<Args extends any[]>(duration?: number, computeKey?: ((...args: Args) => PropertyKey) | PropertyKey, isCacheVoid?: boolean): <T>(originalMethod: (...args: Args) => Promise<T>) => (this: any, ...args: Args) => Promise<NonNullable<T>>;
1
+ export declare function Memoize<Args extends any[]>(duration?: number, computeKey?: ((...args: Args) => PropertyKey) | PropertyKey, isCacheVoid?: boolean): <T>(originalMethod: (...args: Args) => T) => (this: any, ...args: Args) => NonNullable<T>;
package/dist/decorator.js CHANGED
@@ -1,21 +1,23 @@
1
- import { isUndefined as d } from "./utils.js";
2
- function h(o = 0, e = (...t) => t[0], r = !1) {
3
- return function(t) {
4
- const n = /* @__PURE__ */ new Map();
5
- let a = Date.now();
6
- const s = () => o > 0 && a < Date.now();
7
- async function p(...c) {
8
- const i = typeof e == "function" ? e(...c) : e;
9
- if (!n.get(i) || s()) {
10
- a = Date.now() + o;
11
- const f = await t.apply(this, c);
12
- (r || !d(f)) && n.set(i, f);
1
+ import { isUndefined as a } from "./utils.js";
2
+ function m(f = 0, i = (...o) => o[0], c = !1) {
3
+ return function(o) {
4
+ const e = /* @__PURE__ */ new Map();
5
+ let s = Date.now();
6
+ const l = () => f > 0 && s < Date.now();
7
+ function p(...r) {
8
+ const t = typeof i == "function" ? i(...r) : i;
9
+ if (!e.get(t) || l()) {
10
+ s = Date.now() + f;
11
+ const n = o.apply(this, r);
12
+ n instanceof Promise ? (e.set(t, n), n.then((d) => {
13
+ !c && a(d) && e.delete(t);
14
+ })) : (c || !a(n)) && e.set(t, n);
13
15
  }
14
- return n.get(i);
16
+ return e.get(t);
15
17
  }
16
18
  return p;
17
19
  };
18
20
  }
19
21
  export {
20
- h as Memoize
22
+ m as Memoize
21
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlikemario/helper",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A utility library with number operations and common helper functions",
5
5
  "keywords": [
6
6
  "utility",