@js-toolkit/utils
Advanced tools
Comparing version 1.51.0 to 1.51.1
@@ -1,1 +0,3 @@ | ||
export declare function beforeCall<F extends AnyFunction, C extends (...args: Parameters<F>) => void | Promise<void>>(fn: F, beforeCallback: C, context?: any): C extends AnyAsyncFunction ? ((...args: Parameters<F>) => Promise<ReturnType<F>>) & AsObject<F> : F; | ||
export declare function beforeCall<F extends AnyFunction, C extends (...args: Parameters<F>) => void | Promise<void>>(fn: F, beforeCallback: C, | ||
/** Might be a function. */ | ||
context?: unknown): C extends AnyAsyncFunction ? ((...args: Parameters<F>) => Promise<ReturnType<F>>) & AsObject<F> : F; |
@@ -1,1 +0,1 @@ | ||
import{copyFnProps}from"./copyFnProps";export function beforeCall(o,p,r=void 0){return copyFnProps(o,((...n)=>{const e=p.apply(r,n);return e instanceof Promise?e.finally((()=>o.apply(r,n))):o.apply(r,n)}))} | ||
import{copyFnProps}from"./copyFnProps";export function beforeCall(o,n,p=void 0){return copyFnProps(o,(function(...r){const t="function"==typeof p?p():p,c=n.apply(t,r);return c instanceof Promise?c.finally((()=>o.apply(t,r))):o.apply(t,r)}))} |
@@ -1,1 +0,1 @@ | ||
import origin from"lodash.debounce";import{beforeCall}from"./beforeCall";export function debounce(e,n,o){const i=()=>{r.isPending=!1},r=beforeCall(origin(beforeCall(e,i),n,o),(()=>{r.isPending=!0}));return r.isPending=!1,r.cancel=beforeCall(r.cancel.bind(r),i),r} | ||
import origin from"lodash.debounce";import{beforeCall}from"./beforeCall";export function debounce(e,o,n){let r=!1;const l=()=>{r=!1},i=beforeCall(origin(beforeCall(e,l),o,n),(()=>{r=!0}));return i.isPending=r,i.cancel=beforeCall(i.cancel.bind(i),l),Object.defineProperty(i,"isPending",{get:()=>r}),i} |
{ | ||
"name": "@js-toolkit/utils", | ||
"version": "1.51.0", | ||
"version": "1.51.1", | ||
"description": "Typescript helper types and utils", | ||
@@ -26,6 +26,6 @@ "author": "VZH", | ||
"@js-toolkit/configs": "^3.90.0", | ||
"@types/jest": "^29.5.11", | ||
"@types/jest": "^29.5.12", | ||
"@types/lodash.debounce": "^4.0.9", | ||
"@typescript-eslint/eslint-plugin": "^6.19.1", | ||
"@typescript-eslint/parser": "^6.19.1", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"copyfiles": "^2.4.1", | ||
@@ -40,3 +40,3 @@ "eslint": "^8.56.0", | ||
"lodash.debounce": "^4.0.8", | ||
"prettier": "^3.2.4", | ||
"prettier": "^3.2.5", | ||
"rimraf": "^5.0.5", | ||
@@ -43,0 +43,0 @@ "terser": "^5.27.0", |
78019
101
1092