@alwatr/debounce 9.1.0 → 9.2.1

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/main.js CHANGED
@@ -1,5 +1,5 @@
1
- /* 📦 @alwatr/debounce v9.1.0 */
1
+ /* 📦 @alwatr/debounce v9.2.1 */
2
2
  class z{config__;timerId__;maxWaitTimerId__;lastArgs__;constructor(q){this.config__=q;this.config__.trailing??=!0,this.flush=this.flush.bind(this),this.trigger=this.trigger.bind(this),this.cancel=this.cancel.bind(this)}get isPending(){return this.timerId__!==void 0}trigger(...q){if(this.lastArgs__=q,!this.isPending){if(this.config__.maxWait)this.maxWaitTimerId__=setTimeout(this.flush,this.config__.maxWait);if(this.config__.leading===!0)this.invoke__()}else clearTimeout(this.timerId__);this.timerId__=setTimeout(()=>{if(this.config__.trailing===!0)this.invoke__();this.cleanup__()},this.config__.delay)}cancel(){if(this.timerId__)clearTimeout(this.timerId__);if(this.maxWaitTimerId__)clearTimeout(this.maxWaitTimerId__);this.cleanup__()}cleanup__(){delete this.timerId__,delete this.maxWaitTimerId__,delete this.lastArgs__}flush(){if(this.isPending)this.invoke__();this.cancel()}invoke__(){if(this.lastArgs__)this.config__.func.apply(this.config__.thisContext,this.lastArgs__),this.lastArgs__=void 0}}function G(q){return new z(q)}export{G as createDebouncer,z as Debouncer};
3
3
 
4
- //# debugId=AB95AA19FD0CA49764756E2164756E21
4
+ //# debugId=7A92953D2711D79264756E2164756E21
5
5
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -6,6 +6,6 @@
6
6
  "import {Debouncer} from './debounce.js';\n\nimport type {DebouncerConfig} from './type.js';\n\nexport * from './debounce.js';\nexport type * from './type.js';\n\n/**\n * Factory function for creating a Debouncer instance for better type inference.\n * @param config Configuration for the debouncer.\n *\n * @example\n * ```typescript\n * const debouncer = createDebouncer({\n * func: (text: string) => console.log('Searching:', text),\n * delay: 300,\n * leading: false,\n * trailing: true,\n * });\n *\n * // Debounce search input\n * debouncer.trigger('hello');\n * debouncer.trigger('hello world'); // Only 'hello world' will log after 300ms\n *\n * // With custom thisContext\n * const obj = { log: (msg: string) => console.log('Obj:', msg) };\n * const debouncerWithContext = createDebouncer({\n * func: obj.log,\n * thisContext: obj,\n * delay: 200,\n * });\n * debouncerWithContext.trigger('test'); // Logs 'Obj: test'\n * ```\n */\nexport function createDebouncer<F extends AnyFunc>(config: DebouncerConfig<F>): Debouncer<F> {\n return new Debouncer(config);\n}\n"
7
7
  ],
8
8
  "mappings": ";AAgCO,MAAM,CAA6B,CAKX,SAJrB,UACA,iBACA,WAER,WAAW,CAAkB,EAA8B,CAA9B,gBAC3B,KAAK,SAAS,WAAa,GAC3B,KAAK,MAAQ,KAAK,MAAM,KAAK,IAAI,EACjC,KAAK,QAAU,KAAK,QAAQ,KAAK,IAAI,EACrC,KAAK,OAAS,KAAK,OAAO,KAAK,IAAI,KAO1B,UAAS,EAAY,CAC9B,OAAO,KAAK,YAAc,OAoBrB,OAAO,IAAI,EAA2B,CAI3C,GAHA,KAAK,WAAa,EACG,CAAC,KAAK,UAET,CAChB,GAAI,KAAK,SAAS,QAChB,KAAK,iBAAmB,WAAW,KAAK,MAAO,KAAK,SAAS,OAAO,EAEtE,GAAI,KAAK,SAAS,UAAY,GAC5B,KAAK,SAAS,EAIhB,kBAAa,KAAK,SAAU,EAG9B,KAAK,UAAY,WAAW,IAAM,CAChC,GAAI,KAAK,SAAS,WAAa,GAC7B,KAAK,SAAS,EAEhB,KAAK,UAAU,GACd,KAAK,SAAS,KAAK,EAmBjB,MAAM,EAAS,CACpB,GAAI,KAAK,UACP,aAAa,KAAK,SAAS,EAE7B,GAAI,KAAK,iBACP,aAAa,KAAK,gBAAgB,EAEpC,KAAK,UAAU,EAMT,SAAS,EAAS,CACxB,OAAO,KAAK,UACZ,OAAO,KAAK,iBACZ,OAAO,KAAK,WAqBP,KAAK,EAAS,CACnB,GAAI,KAAK,UACP,KAAK,SAAS,EAEhB,KAAK,OAAO,EAMN,QAAQ,EAAS,CACvB,GAAI,KAAK,WAEP,KAAK,SAAS,KAAK,MAAM,KAAK,SAAS,YAAa,KAAK,UAAU,EACnE,KAAK,WAAa,OAGxB,CCjIO,SAAS,CAAkC,CAAC,EAA0C,CAC3F,OAAO,IAAI,EAAU,CAAM",
9
- "debugId": "AB95AA19FD0CA49764756E2164756E21",
9
+ "debugId": "7A92953D2711D79264756E2164756E21",
10
10
  "names": []
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwatr/debounce",
3
- "version": "9.1.0",
3
+ "version": "9.2.1",
4
4
  "description": "A powerful, modern, and type-safe debouncer utility designed for high-performance applications. It's framework-agnostic, works seamlessly in both Node.js and browsers, and provides a rich API for fine-grained control over function execution.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/Alwatr/alwatr",
11
11
  "directory": "pkg/nanolib/debounce"
12
12
  },
13
- "homepage": "https://github.com/Alwatr/alwatr/tree/main/pkg/nanolib/debounce#readme",
13
+ "homepage": "https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/debounce#readme",
14
14
  "bugs": "https://github.com/Alwatr/alwatr/issues",
15
15
  "exports": {
16
16
  ".": {
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "sideEffects": false,
23
23
  "devDependencies": {
24
- "@alwatr/nano-build": "9.1.0",
25
- "@alwatr/tsconfig-base": "9.1.0",
26
- "@alwatr/type-helper": "9.1.0",
27
- "@types/node": "^25.5.0",
24
+ "@alwatr/nano-build": "9.1.1",
25
+ "@alwatr/tsconfig-base": "9.1.1",
26
+ "@alwatr/type-helper": "9.1.1",
27
+ "@types/node": "^24.12.2",
28
28
  "typescript": "^6.0.2"
29
29
  },
30
30
  "scripts": {
@@ -77,5 +77,5 @@
77
77
  "util",
78
78
  "utility"
79
79
  ],
80
- "gitHead": "4a25cd3e0499cf61dd761e87d3711abf9b0cd208"
80
+ "gitHead": "b9dc0cb8b04b16216d44fbe9a9682f2a57926167"
81
81
  }