@zlikemario/helper 0.0.4 → 0.0.6

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 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;
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 +1 @@
1
- export declare function memoize<Args extends unknown[]>(duration?: number, computeKey?: (...args: Args) => unknown, isCacheVoid?: boolean): <T>(_: unknown, _key: string, descriptor: TypedPropertyDescriptor<(...args: Args) => Promise<T>>) => TypedPropertyDescriptor<(...args: Args) => Promise<T>> | void;
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>>;
package/dist/decorator.js CHANGED
@@ -1,20 +1,21 @@
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);
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);
13
13
  }
14
- return n.get(t);
15
- }, e;
14
+ return n.get(i);
15
+ }
16
+ return p;
16
17
  };
17
18
  }
18
19
  export {
19
- p as memoize
20
+ h as Memoize
20
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlikemario/helper",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A utility library with number operations and common helper functions",
5
5
  "keywords": [
6
6
  "utility",
@@ -28,8 +28,7 @@
28
28
  "build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
29
29
  "preview": "vite preview",
30
30
  "test": "vitest",
31
- "prepublishOnly": "yarn build",
32
- "publish": "npm publish --access public"
31
+ "prepublishOnly": "yarn build"
33
32
  },
34
33
  "devDependencies": {
35
34
  "@types/node": "^24",
@@ -71,4 +70,4 @@
71
70
  "bignumber.js": "*",
72
71
  "dayjs": "*"
73
72
  }
74
- }
73
+ }