@alwatr/debounce 2.0.2 → 9.1.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 +2 -2
- package/dist/main.js.map +1 -1
- package/dist/type.d.ts.map +1 -1
- package/package.json +21 -20
- package/src/type.ts +0 -1
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/debounce
|
|
1
|
+
/* 📦 @alwatr/debounce v9.1.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=
|
|
4
|
+
//# debugId=46A719CB1C4FC0AC64756E2164756E21
|
|
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": "
|
|
9
|
+
"debugId": "46A719CB1C4FC0AC64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,OAAO;IAChD;;;OAGG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;;;OAIG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAEnC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/debounce",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.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
|
-
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
|
+
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
|
-
"directory": "packages/debounce",
|
|
10
9
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Alwatr/
|
|
10
|
+
"url": "https://github.com/Alwatr/alwatr",
|
|
11
|
+
"directory": "pkg/nanolib/debounce"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/Alwatr/
|
|
14
|
-
"bugs": "https://github.com/Alwatr/
|
|
13
|
+
"homepage": "https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/debounce#readme",
|
|
14
|
+
"bugs": "https://github.com/Alwatr/alwatr/issues",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/main.d.ts",
|
|
18
|
+
"import": "./dist/main.js",
|
|
18
19
|
"default": "./dist/main.js"
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": false,
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@alwatr/nano-build": "
|
|
24
|
-
"@alwatr/
|
|
25
|
-
"@alwatr/
|
|
26
|
-
"@
|
|
27
|
-
"@types/node": "^24.12.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": "^25.5.0",
|
|
28
28
|
"typescript": "^6.0.2"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
@@ -32,21 +32,23 @@
|
|
|
32
32
|
"build": "bun run build:ts && bun run build:es",
|
|
33
33
|
"build:es": "nano-build --preset=module src/main.ts",
|
|
34
34
|
"build:ts": "tsc --build",
|
|
35
|
-
"
|
|
36
|
-
"cb": "bun run clean && bun run build",
|
|
35
|
+
"cl": "bun run clean",
|
|
37
36
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
38
|
-
"
|
|
37
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
38
|
+
"lint": "eslint src/ --ext .ts",
|
|
39
|
+
"t": "bun run test",
|
|
40
|
+
"test": "ALWATR_DEBUG=0 bun test",
|
|
39
41
|
"w": "bun run watch",
|
|
40
42
|
"watch": "bun run watch:ts & bun run watch:es",
|
|
41
43
|
"watch:es": "bun run build:es --watch",
|
|
42
44
|
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
43
45
|
},
|
|
44
46
|
"files": [
|
|
45
|
-
"
|
|
47
|
+
"dist",
|
|
48
|
+
"src/**/*.ts",
|
|
49
|
+
"!src/**/*.test.ts",
|
|
46
50
|
"README.md",
|
|
47
|
-
"LICENSE"
|
|
48
|
-
"!demo/**/*",
|
|
49
|
-
"!**/*.test.js"
|
|
51
|
+
"LICENSE"
|
|
50
52
|
],
|
|
51
53
|
"publishConfig": {
|
|
52
54
|
"access": "public"
|
|
@@ -75,6 +77,5 @@
|
|
|
75
77
|
"util",
|
|
76
78
|
"utility"
|
|
77
79
|
],
|
|
78
|
-
"
|
|
79
|
-
"gitHead": "95bb13efd0a5f485c6b09f1a911b99492017aed1"
|
|
80
|
+
"gitHead": "38fb79dd8b6cf48108ae6492ecd7a285c7633e9b"
|
|
80
81
|
}
|
package/src/type.ts
CHANGED