@resq-sw/decorators 0.1.0

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.
Files changed (187) hide show
  1. package/README.md +277 -0
  2. package/lib/_utils.d.ts +46 -0
  3. package/lib/_utils.d.ts.map +1 -0
  4. package/lib/_utils.js +91 -0
  5. package/lib/_utils.js.map +1 -0
  6. package/lib/after/after.d.ts +60 -0
  7. package/lib/after/after.d.ts.map +1 -0
  8. package/lib/after/after.fn.d.ts +39 -0
  9. package/lib/after/after.fn.d.ts.map +1 -0
  10. package/lib/after/after.fn.js +59 -0
  11. package/lib/after/after.fn.js.map +1 -0
  12. package/lib/after/after.js +41 -0
  13. package/lib/after/after.js.map +1 -0
  14. package/lib/after/after.types.d.ts +86 -0
  15. package/lib/after/after.types.d.ts.map +1 -0
  16. package/lib/after/after.types.js +0 -0
  17. package/lib/after/index.d.ts +3 -0
  18. package/lib/after/index.js +2 -0
  19. package/lib/before/before.d.ts +61 -0
  20. package/lib/before/before.d.ts.map +1 -0
  21. package/lib/before/before.fn.d.ts +39 -0
  22. package/lib/before/before.fn.d.ts.map +1 -0
  23. package/lib/before/before.fn.js +51 -0
  24. package/lib/before/before.fn.js.map +1 -0
  25. package/lib/before/before.js +40 -0
  26. package/lib/before/before.js.map +1 -0
  27. package/lib/before/before.types.d.ts +48 -0
  28. package/lib/before/before.types.d.ts.map +1 -0
  29. package/lib/before/before.types.js +0 -0
  30. package/lib/before/index.d.ts +3 -0
  31. package/lib/before/index.js +2 -0
  32. package/lib/bind/bind.d.ts +75 -0
  33. package/lib/bind/bind.d.ts.map +1 -0
  34. package/lib/bind/bind.fn.d.ts +46 -0
  35. package/lib/bind/bind.fn.d.ts.map +1 -0
  36. package/lib/bind/bind.fn.js +39 -0
  37. package/lib/bind/bind.fn.js.map +1 -0
  38. package/lib/bind/bind.js +64 -0
  39. package/lib/bind/bind.js.map +1 -0
  40. package/lib/bind/bind.types.d.ts +36 -0
  41. package/lib/bind/bind.types.d.ts.map +1 -0
  42. package/lib/bind/bind.types.js +0 -0
  43. package/lib/bind/index.d.ts +3 -0
  44. package/lib/bind/index.js +2 -0
  45. package/lib/debounce/debounce.d.ts +34 -0
  46. package/lib/debounce/debounce.d.ts.map +1 -0
  47. package/lib/debounce/debounce.fn.d.ts +40 -0
  48. package/lib/debounce/debounce.fn.d.ts.map +1 -0
  49. package/lib/debounce/debounce.fn.js +47 -0
  50. package/lib/debounce/debounce.fn.js.map +1 -0
  51. package/lib/debounce/debounce.js +48 -0
  52. package/lib/debounce/debounce.js.map +1 -0
  53. package/lib/debounce/index.d.ts +2 -0
  54. package/lib/debounce/index.js +2 -0
  55. package/lib/delay/delay.d.ts +35 -0
  56. package/lib/delay/delay.d.ts.map +1 -0
  57. package/lib/delay/delay.fn.d.ts +33 -0
  58. package/lib/delay/delay.fn.d.ts.map +1 -0
  59. package/lib/delay/delay.fn.js +38 -0
  60. package/lib/delay/delay.fn.js.map +1 -0
  61. package/lib/delay/delay.js +43 -0
  62. package/lib/delay/delay.js.map +1 -0
  63. package/lib/delay/index.d.ts +2 -0
  64. package/lib/delay/index.js +2 -0
  65. package/lib/delegate/delegate.d.ts +48 -0
  66. package/lib/delegate/delegate.d.ts.map +1 -0
  67. package/lib/delegate/delegate.fn.d.ts +57 -0
  68. package/lib/delegate/delegate.fn.d.ts.map +1 -0
  69. package/lib/delegate/delegate.fn.js +55 -0
  70. package/lib/delegate/delegate.fn.js.map +1 -0
  71. package/lib/delegate/delegate.js +56 -0
  72. package/lib/delegate/delegate.js.map +1 -0
  73. package/lib/delegate/delegate.types.d.ts +45 -0
  74. package/lib/delegate/delegate.types.d.ts.map +1 -0
  75. package/lib/delegate/delegate.types.js +0 -0
  76. package/lib/delegate/index.d.ts +3 -0
  77. package/lib/delegate/index.js +2 -0
  78. package/lib/exec-time/exec-time.d.ts +42 -0
  79. package/lib/exec-time/exec-time.d.ts.map +1 -0
  80. package/lib/exec-time/exec-time.fn.d.ts +50 -0
  81. package/lib/exec-time/exec-time.fn.d.ts.map +1 -0
  82. package/lib/exec-time/exec-time.fn.js +91 -0
  83. package/lib/exec-time/exec-time.fn.js.map +1 -0
  84. package/lib/exec-time/exec-time.js +55 -0
  85. package/lib/exec-time/exec-time.js.map +1 -0
  86. package/lib/exec-time/exec-time.types.d.ts +70 -0
  87. package/lib/exec-time/exec-time.types.d.ts.map +1 -0
  88. package/lib/exec-time/exec-time.types.js +0 -0
  89. package/lib/exec-time/index.d.ts +4 -0
  90. package/lib/exec-time/index.js +3 -0
  91. package/lib/execute/execute.d.ts +78 -0
  92. package/lib/execute/execute.d.ts.map +1 -0
  93. package/lib/execute/execute.js +82 -0
  94. package/lib/execute/execute.js.map +1 -0
  95. package/lib/execute/index.d.ts +2 -0
  96. package/lib/execute/index.js +2 -0
  97. package/lib/index.d.ts +30 -0
  98. package/lib/index.js +19 -0
  99. package/lib/memoize/index.d.ts +3 -0
  100. package/lib/memoize/index.js +2 -0
  101. package/lib/memoize/memoize.d.ts +67 -0
  102. package/lib/memoize/memoize.d.ts.map +1 -0
  103. package/lib/memoize/memoize.fn.d.ts +69 -0
  104. package/lib/memoize/memoize.fn.d.ts.map +1 -0
  105. package/lib/memoize/memoize.fn.js +43 -0
  106. package/lib/memoize/memoize.fn.js.map +1 -0
  107. package/lib/memoize/memoize.js +40 -0
  108. package/lib/memoize/memoize.js.map +1 -0
  109. package/lib/memoize/memoize.types.d.ts +107 -0
  110. package/lib/memoize/memoize.types.d.ts.map +1 -0
  111. package/lib/memoize/memoize.types.js +0 -0
  112. package/lib/memoize-async/index.d.ts +4 -0
  113. package/lib/memoize-async/index.js +3 -0
  114. package/lib/memoize-async/memoize-async.d.ts +68 -0
  115. package/lib/memoize-async/memoize-async.d.ts.map +1 -0
  116. package/lib/memoize-async/memoize-async.fn.d.ts +69 -0
  117. package/lib/memoize-async/memoize-async.fn.d.ts.map +1 -0
  118. package/lib/memoize-async/memoize-async.fn.js +52 -0
  119. package/lib/memoize-async/memoize-async.fn.js.map +1 -0
  120. package/lib/memoize-async/memoize-async.js +15 -0
  121. package/lib/memoize-async/memoize-async.js.map +1 -0
  122. package/lib/memoize-async/memoize-async.types.d.ts +74 -0
  123. package/lib/memoize-async/memoize-async.types.d.ts.map +1 -0
  124. package/lib/memoize-async/memoize-async.types.js +0 -0
  125. package/lib/observer/index.d.ts +3 -0
  126. package/lib/observer/index.js +2 -0
  127. package/lib/observer/observer.d.ts +54 -0
  128. package/lib/observer/observer.d.ts.map +1 -0
  129. package/lib/observer/observer.js +85 -0
  130. package/lib/observer/observer.js.map +1 -0
  131. package/lib/observer/observer.types.d.ts +41 -0
  132. package/lib/observer/observer.types.d.ts.map +1 -0
  133. package/lib/observer/observer.types.js +0 -0
  134. package/lib/rate-limit/index.d.ts +4 -0
  135. package/lib/rate-limit/index.js +3 -0
  136. package/lib/rate-limit/rate-limit.d.ts +58 -0
  137. package/lib/rate-limit/rate-limit.d.ts.map +1 -0
  138. package/lib/rate-limit/rate-limit.fn.d.ts +43 -0
  139. package/lib/rate-limit/rate-limit.fn.d.ts.map +1 -0
  140. package/lib/rate-limit/rate-limit.fn.js +56 -0
  141. package/lib/rate-limit/rate-limit.fn.js.map +1 -0
  142. package/lib/rate-limit/rate-limit.js +65 -0
  143. package/lib/rate-limit/rate-limit.js.map +1 -0
  144. package/lib/rate-limit/rate-limit.types.d.ts +148 -0
  145. package/lib/rate-limit/rate-limit.types.d.ts.map +1 -0
  146. package/lib/rate-limit/rate-limit.types.js +0 -0
  147. package/lib/rate-limit/simple-rate-limit-counter.d.ts +89 -0
  148. package/lib/rate-limit/simple-rate-limit-counter.d.ts.map +1 -0
  149. package/lib/rate-limit/simple-rate-limit-counter.js +98 -0
  150. package/lib/rate-limit/simple-rate-limit-counter.js.map +1 -0
  151. package/lib/readonly/index.d.ts +3 -0
  152. package/lib/readonly/index.js +2 -0
  153. package/lib/readonly/readonly.d.ts +39 -0
  154. package/lib/readonly/readonly.d.ts.map +1 -0
  155. package/lib/readonly/readonly.js +43 -0
  156. package/lib/readonly/readonly.js.map +1 -0
  157. package/lib/readonly/readonly.types.d.ts +40 -0
  158. package/lib/readonly/readonly.types.d.ts.map +1 -0
  159. package/lib/readonly/readonly.types.js +0 -0
  160. package/lib/throttle/index.d.ts +2 -0
  161. package/lib/throttle/index.js +2 -0
  162. package/lib/throttle/throttle.d.ts +35 -0
  163. package/lib/throttle/throttle.d.ts.map +1 -0
  164. package/lib/throttle/throttle.fn.d.ts +42 -0
  165. package/lib/throttle/throttle.fn.d.ts.map +1 -0
  166. package/lib/throttle/throttle.fn.js +52 -0
  167. package/lib/throttle/throttle.fn.js.map +1 -0
  168. package/lib/throttle/throttle.js +43 -0
  169. package/lib/throttle/throttle.js.map +1 -0
  170. package/lib/throttle-async/index.d.ts +2 -0
  171. package/lib/throttle-async/index.js +2 -0
  172. package/lib/throttle-async/throttle-async-executor.d.ts +79 -0
  173. package/lib/throttle-async/throttle-async-executor.d.ts.map +1 -0
  174. package/lib/throttle-async/throttle-async-executor.js +122 -0
  175. package/lib/throttle-async/throttle-async-executor.js.map +1 -0
  176. package/lib/throttle-async/throttle-async.d.ts +68 -0
  177. package/lib/throttle-async/throttle-async.d.ts.map +1 -0
  178. package/lib/throttle-async/throttle-async.fn.d.ts +41 -0
  179. package/lib/throttle-async/throttle-async.fn.d.ts.map +1 -0
  180. package/lib/throttle-async/throttle-async.fn.js +46 -0
  181. package/lib/throttle-async/throttle-async.fn.js.map +1 -0
  182. package/lib/throttle-async/throttle-async.js +45 -0
  183. package/lib/throttle-async/throttle-async.js.map +1 -0
  184. package/lib/types.d.ts +81 -0
  185. package/lib/types.d.ts.map +1 -0
  186. package/lib/types.js +0 -0
  187. package/package.json +40 -0
@@ -0,0 +1,45 @@
1
+ import { AsyncMethod } from "../types.js";
2
+
3
+ //#region src/delegate/delegate.types.d.ts
4
+ /**
5
+ * @fileoverview Type definitions for the Delegate decorator.
6
+ * Provides the Delegatable type for method decorators that deduplicate async calls.
7
+ *
8
+ * @module @resq/typescript/decorators/delegate/types
9
+ *
10
+ * @copyright Copyright (c) 2026 ResQ
11
+ * @license MIT
12
+ */
13
+ /**
14
+ * @fileoverview Type definitions for the Delegate decorator.
15
+ * Provides the Delegatable type for method decorators that deduplicate async calls.
16
+ *
17
+ * @module @resq/typescript/decorators/delegate/types
18
+ *
19
+ * @copyright Copyright (c) 2026 ResQ
20
+ * @license MIT
21
+ */
22
+ /**
23
+ * Type for the @delegate decorator function.
24
+ * Transforms an async method into one that deduplicates concurrent calls.
25
+ *
26
+ * @template T - The type of the class containing the decorated method
27
+ * @template D - The return type of the decorated async method
28
+ *
29
+ * @param {T} target - The class prototype
30
+ * @param {keyof T} propertyName - The name of the method being decorated
31
+ * @param {TypedPropertyDescriptor<AsyncMethod<D>>} descriptor - The property descriptor
32
+ * @returns {TypedPropertyDescriptor<AsyncMethod<D>>} The modified descriptor
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * type MyDelegatable = Delegatable<MyService, User>;
37
+ *
38
+ * // Usage in decorator factory
39
+ * const decorator: MyDelegatable = delegate((id) => id);
40
+ * ```
41
+ */
42
+ type Delegatable<T, D> = (target: T, propertyName: keyof T, descriptor: TypedPropertyDescriptor<AsyncMethod<D>>) => TypedPropertyDescriptor<AsyncMethod<D>>;
43
+ //#endregion
44
+ export { Delegatable };
45
+ //# sourceMappingURL=delegate.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate.types.d.ts","names":[],"sources":["../../src/delegate/delegate.types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+DY,WAAA,UACV,MAAA,EAAQ,CAAA,EACR,YAAA,QAAoB,CAAA,EACpB,UAAA,EAAY,uBAAA,CAAwB,WAAA,CAAY,CAAA,OAC7C,uBAAA,CAAwB,WAAA,CAAY,CAAA"}
File without changes
@@ -0,0 +1,3 @@
1
+ import { Delegatable } from "./delegate.types.js";
2
+ import { delegate } from "./delegate.js";
3
+ export { Delegatable, delegate };
@@ -0,0 +1,2 @@
1
+ import { delegate } from "./delegate.js";
2
+ export { delegate };
@@ -0,0 +1,42 @@
1
+ import { ReportFunction } from "./exec-time.types.js";
2
+
3
+ //#region src/exec-time/exec-time.d.ts
4
+ /**
5
+ * Decorator that measures and reports the execution time of methods.
6
+ * Supports both legacy (TypeScript) and standard (Stage 3) decorator formats.
7
+ *
8
+ * @param {ReportFunction | string} [arg] - Optional reporter function or label string
9
+ * @returns {any} The decorator function
10
+ *
11
+ * @throws {Error} When applied to a non-method property
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * class PerformanceMonitor {
16
+ * // Uses default console reporter
17
+ * @execTime()
18
+ * processData(data: any[]): void {
19
+ * // Processing...
20
+ * }
21
+ *
22
+ * // Uses custom label
23
+ * @execTime('Database Query')
24
+ * async fetchUsers(): Promise<User[]> {
25
+ * return db.users.findAll();
26
+ * }
27
+ *
28
+ * // Uses custom reporter function
29
+ * @execTime((data) => {
30
+ * metrics.histogram('method_duration', data.execTime);
31
+ * console.log(`${data.execTime}ms: ${data.args.join(', ')}`);
32
+ * })
33
+ * heavyCalculation(input: number): number {
34
+ * return input ** 2;
35
+ * }
36
+ * }
37
+ * ```
38
+ */
39
+ declare function execTime<T = any>(arg?: ReportFunction | string): any;
40
+ //#endregion
41
+ export { execTime };
42
+ //# sourceMappingURL=exec-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-time.d.ts","names":[],"sources":["../../src/exec-time/exec-time.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFgB,QAAA,SAAA,CAAkB,GAAA,GAAM,cAAA"}
@@ -0,0 +1,50 @@
1
+ import { AsyncMethod, Method } from "../types.js";
2
+ import { ReportFunction } from "./exec-time.types.js";
3
+
4
+ //#region src/exec-time/exec-time.fn.d.ts
5
+ /**
6
+ * Wraps a method to measure and report its execution time.
7
+ * Handles both synchronous and asynchronous methods.
8
+ *
9
+ * @template D - The return type of the original method
10
+ * @template A - The argument types of the original method
11
+ * @param {Method<D, A> | AsyncMethod<D, A>} originalMethod - The method to wrap
12
+ * @param {ReportFunction | string} [arg] - Optional reporter function or label
13
+ * @returns {AsyncMethod<void, A>} The wrapped method
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * class Calculator {
18
+ * fibonacci(n: number): number {
19
+ * if (n <= 1) return n;
20
+ * return this.fibonacci(n - 1) + this.fibonacci(n - 2);
21
+ * }
22
+ * }
23
+ *
24
+ * const calc = new Calculator();
25
+ *
26
+ * // Wrap with default reporter
27
+ * const timed = execTimeFn(calc.fibonacci.bind(calc));
28
+ * await timed(40); // Logs: "Execution time: 450ms"
29
+ *
30
+ * // Wrap with custom label
31
+ * const labeled = execTimeFn(
32
+ * calc.fibonacci.bind(calc),
33
+ * 'Fibonacci calculation'
34
+ * );
35
+ * await labeled(40); // Logs: "Fibonacci calculation execution time: 450ms"
36
+ *
37
+ * // Wrap with custom reporter
38
+ * const custom = execTimeFn(
39
+ * calc.fibonacci.bind(calc),
40
+ * (data) => {
41
+ * console.log(`Took ${data.execTime}ms for n=${data.args[0]}`);
42
+ * }
43
+ * );
44
+ * await custom(40); // Logs: "Took 450ms for n=40"
45
+ * ```
46
+ */
47
+ declare function execTimeFn<D = any, A extends any[] = any[]>(originalMethod: Method<D, A> | AsyncMethod<D, A>, arg?: ReportFunction | string): AsyncMethod<void, A>;
48
+ //#endregion
49
+ export { execTimeFn };
50
+ //# sourceMappingURL=exec-time.fn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-time.fn.d.ts","names":[],"sources":["../../src/exec-time/exec-time.fn.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwEgB,UAAA,kCAAA,CACd,cAAA,EAAgB,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,WAAA,CAAY,CAAA,EAAG,CAAA,GAC9C,GAAA,GAAM,cAAA,YACL,WAAA,OAAkB,CAAA"}
@@ -0,0 +1,91 @@
1
+ import { isPromise, logger } from "../_utils.js";
2
+ //#region src/exec-time/exec-time.fn.ts
3
+ /**
4
+ * Copyright 2026 ResQ
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ /**
19
+ * Default reporter function that logs execution time using the logger.
20
+ *
21
+ * @param {ExactTimeReportData} data - The execution data
22
+ * @returns {void}
23
+ */
24
+ const reporter = (data) => {
25
+ logger.info(`Execution time: ${data.execTime}ms`);
26
+ };
27
+ /**
28
+ * Wraps a method to measure and report its execution time.
29
+ * Handles both synchronous and asynchronous methods.
30
+ *
31
+ * @template D - The return type of the original method
32
+ * @template A - The argument types of the original method
33
+ * @param {Method<D, A> | AsyncMethod<D, A>} originalMethod - The method to wrap
34
+ * @param {ReportFunction | string} [arg] - Optional reporter function or label
35
+ * @returns {AsyncMethod<void, A>} The wrapped method
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * class Calculator {
40
+ * fibonacci(n: number): number {
41
+ * if (n <= 1) return n;
42
+ * return this.fibonacci(n - 1) + this.fibonacci(n - 2);
43
+ * }
44
+ * }
45
+ *
46
+ * const calc = new Calculator();
47
+ *
48
+ * // Wrap with default reporter
49
+ * const timed = execTimeFn(calc.fibonacci.bind(calc));
50
+ * await timed(40); // Logs: "Execution time: 450ms"
51
+ *
52
+ * // Wrap with custom label
53
+ * const labeled = execTimeFn(
54
+ * calc.fibonacci.bind(calc),
55
+ * 'Fibonacci calculation'
56
+ * );
57
+ * await labeled(40); // Logs: "Fibonacci calculation execution time: 450ms"
58
+ *
59
+ * // Wrap with custom reporter
60
+ * const custom = execTimeFn(
61
+ * calc.fibonacci.bind(calc),
62
+ * (data) => {
63
+ * console.log(`Took ${data.execTime}ms for n=${data.args[0]}`);
64
+ * }
65
+ * );
66
+ * await custom(40); // Logs: "Took 450ms for n=40"
67
+ * ```
68
+ */
69
+ function execTimeFn(originalMethod, arg) {
70
+ const input = arg ?? reporter;
71
+ return async function(...args) {
72
+ let repFunc;
73
+ if (typeof input === "string") if (typeof this[input] === "function") repFunc = this[input].bind(this);
74
+ else repFunc = (data) => {
75
+ logger.info(`${input} execution time`, { duration: `${data.execTime}ms` });
76
+ };
77
+ else repFunc = input;
78
+ const start = Date.now();
79
+ let result = originalMethod.apply(this, args);
80
+ if (isPromise(result)) result = await result;
81
+ repFunc({
82
+ args,
83
+ result,
84
+ execTime: Date.now() - start
85
+ });
86
+ };
87
+ }
88
+ //#endregion
89
+ export { execTimeFn };
90
+
91
+ //# sourceMappingURL=exec-time.fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-time.fn.js","names":[],"sources":["../../src/exec-time/exec-time.fn.ts"],"sourcesContent":["/**\n * Copyright 2026 ResQ\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isPromise, logger } from '../_utils.js';\nimport type { AsyncMethod, Method } from '../types.js';\nimport type { ExactTimeReportData, ReportFunction } from './exec-time.types.js';\n\n/**\n * Default reporter function that logs execution time using the logger.\n *\n * @param {ExactTimeReportData} data - The execution data\n * @returns {void}\n */\nconst reporter: ReportFunction = (data: ExactTimeReportData): void => {\n logger.info(`Execution time: ${data.execTime}ms`);\n};\n\n/**\n * Wraps a method to measure and report its execution time.\n * Handles both synchronous and asynchronous methods.\n *\n * @template D - The return type of the original method\n * @template A - The argument types of the original method\n * @param {Method<D, A> | AsyncMethod<D, A>} originalMethod - The method to wrap\n * @param {ReportFunction | string} [arg] - Optional reporter function or label\n * @returns {AsyncMethod<void, A>} The wrapped method\n *\n * @example\n * ```typescript\n * class Calculator {\n * fibonacci(n: number): number {\n * if (n <= 1) return n;\n * return this.fibonacci(n - 1) + this.fibonacci(n - 2);\n * }\n * }\n *\n * const calc = new Calculator();\n *\n * // Wrap with default reporter\n * const timed = execTimeFn(calc.fibonacci.bind(calc));\n * await timed(40); // Logs: \"Execution time: 450ms\"\n *\n * // Wrap with custom label\n * const labeled = execTimeFn(\n * calc.fibonacci.bind(calc),\n * 'Fibonacci calculation'\n * );\n * await labeled(40); // Logs: \"Fibonacci calculation execution time: 450ms\"\n *\n * // Wrap with custom reporter\n * const custom = execTimeFn(\n * calc.fibonacci.bind(calc),\n * (data) => {\n * console.log(`Took ${data.execTime}ms for n=${data.args[0]}`);\n * }\n * );\n * await custom(40); // Logs: \"Took 450ms for n=40\"\n * ```\n */\nexport function execTimeFn<D = any, A extends any[] = any[]>(\n originalMethod: Method<D, A> | AsyncMethod<D, A>,\n arg?: ReportFunction | string,\n): AsyncMethod<void, A> {\n const input: ReportFunction | string = arg ?? reporter;\n\n return async function (this: any, ...args: A): Promise<void> {\n let repFunc: ReportFunction;\n\n if (typeof input === 'string') {\n if (typeof this[input] === 'function') {\n repFunc = this[input].bind(this);\n } else {\n repFunc = (data) => {\n logger.info(`${input} execution time`, { duration: `${data.execTime}ms` });\n };\n }\n } else {\n repFunc = input;\n }\n\n const start = Date.now();\n let result = (originalMethod as Function).apply(this, args);\n\n if (isPromise(result)) {\n result = await result;\n }\n\n repFunc({\n args,\n result,\n execTime: Date.now() - start,\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,YAA4B,SAAoC;AACpE,QAAO,KAAK,mBAAmB,KAAK,SAAS,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CnD,SAAgB,WACd,gBACA,KACsB;CACtB,MAAM,QAAiC,OAAO;AAE9C,QAAO,eAA2B,GAAG,MAAwB;EAC3D,IAAI;AAEJ,MAAI,OAAO,UAAU,SACnB,KAAI,OAAO,KAAK,WAAW,WACzB,WAAU,KAAK,OAAO,KAAK,KAAK;MAEhC,YAAW,SAAS;AAClB,UAAO,KAAK,GAAG,MAAM,kBAAkB,EAAE,UAAU,GAAG,KAAK,SAAS,KAAK,CAAC;;MAI9E,WAAU;EAGZ,MAAM,QAAQ,KAAK,KAAK;EACxB,IAAI,SAAU,eAA4B,MAAM,MAAM,KAAK;AAE3D,MAAI,UAAU,OAAO,CACnB,UAAS,MAAM;AAGjB,UAAQ;GACN;GACA;GACA,UAAU,KAAK,KAAK,GAAG;GACxB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { execTimeFn } from "./exec-time.fn.js";
2
+ //#region src/exec-time/exec-time.ts
3
+ /**
4
+ * Decorator that measures and reports the execution time of methods.
5
+ * Supports both legacy (TypeScript) and standard (Stage 3) decorator formats.
6
+ *
7
+ * @param {ReportFunction | string} [arg] - Optional reporter function or label string
8
+ * @returns {any} The decorator function
9
+ *
10
+ * @throws {Error} When applied to a non-method property
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * class PerformanceMonitor {
15
+ * // Uses default console reporter
16
+ * @execTime()
17
+ * processData(data: any[]): void {
18
+ * // Processing...
19
+ * }
20
+ *
21
+ * // Uses custom label
22
+ * @execTime('Database Query')
23
+ * async fetchUsers(): Promise<User[]> {
24
+ * return db.users.findAll();
25
+ * }
26
+ *
27
+ * // Uses custom reporter function
28
+ * @execTime((data) => {
29
+ * metrics.histogram('method_duration', data.execTime);
30
+ * console.log(`${data.execTime}ms: ${data.args.join(', ')}`);
31
+ * })
32
+ * heavyCalculation(input: number): number {
33
+ * return input ** 2;
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ function execTime(arg) {
39
+ return (targetOrValue, propertyNameOrContext, descriptor) => {
40
+ if (descriptor) {
41
+ if (descriptor.value) {
42
+ descriptor.value = execTimeFn(descriptor.value, arg);
43
+ return descriptor;
44
+ }
45
+ throw new Error("@execTime is applicable only on methods.");
46
+ }
47
+ const method = targetOrValue;
48
+ if (propertyNameOrContext.kind === "method") return execTimeFn(method, arg);
49
+ throw new Error("@execTime is applicable only on methods.");
50
+ };
51
+ }
52
+ //#endregion
53
+ export { execTime };
54
+
55
+ //# sourceMappingURL=exec-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-time.js","names":[],"sources":["../../src/exec-time/exec-time.ts"],"sourcesContent":["/**\n * Copyright 2026 ResQ\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview ExecTime decorator - measures and reports the execution time of methods.\n * Useful for performance monitoring and debugging slow operations.\n *\n * @module @resq/typescript/decorators/exec-time\n *\n * @example\n * ```typescript\n * class DataService {\n * @execTime()\n * async fetchLargeDataset(): Promise<Data[]> {\n * return await database.query('SELECT * FROM large_table');\n * }\n *\n * @execTime('Heavy computation')\n * computePrimes(n: number): number[] {\n * // ... computation\n * }\n * }\n * ```\n *\n * @copyright Copyright (c) 2026 ResQ\n * @license MIT\n */\n\nimport type { AsyncMethod, Method } from '../types.js';\nimport { execTimeFn } from './exec-time.fn.js';\nimport type { ReportFunction } from './exec-time.types.js';\n\n/**\n * Decorator that measures and reports the execution time of methods.\n * Supports both legacy (TypeScript) and standard (Stage 3) decorator formats.\n *\n * @param {ReportFunction | string} [arg] - Optional reporter function or label string\n * @returns {any} The decorator function\n *\n * @throws {Error} When applied to a non-method property\n *\n * @example\n * ```typescript\n * class PerformanceMonitor {\n * // Uses default console reporter\n * @execTime()\n * processData(data: any[]): void {\n * // Processing...\n * }\n *\n * // Uses custom label\n * @execTime('Database Query')\n * async fetchUsers(): Promise<User[]> {\n * return db.users.findAll();\n * }\n *\n * // Uses custom reporter function\n * @execTime((data) => {\n * metrics.histogram('method_duration', data.execTime);\n * console.log(`${data.execTime}ms: ${data.args.join(', ')}`);\n * })\n * heavyCalculation(input: number): number {\n * return input ** 2;\n * }\n * }\n * ```\n */\nexport function execTime<T = any>(arg?: ReportFunction | string): any {\n return (\n targetOrValue: unknown,\n propertyNameOrContext: keyof T | ClassMethodDecoratorContext,\n descriptor?: TypedPropertyDescriptor<any>,\n ): any => {\n // Legacy decorator\n if (descriptor) {\n if (descriptor.value) {\n descriptor.value = execTimeFn(descriptor.value, arg);\n return descriptor;\n }\n throw new Error('@execTime is applicable only on methods.');\n }\n\n // Standard decorator (Stage 3)\n // targetOrValue is the method itself\n // propertyNameOrContext is the context\n const method = targetOrValue as Method | AsyncMethod;\n const context = propertyNameOrContext as ClassMethodDecoratorContext;\n\n if (context.kind === 'method') {\n return execTimeFn(method, arg);\n }\n\n throw new Error('@execTime is applicable only on methods.');\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAgB,SAAkB,KAAoC;AACpE,SACE,eACA,uBACA,eACQ;AAER,MAAI,YAAY;AACd,OAAI,WAAW,OAAO;AACpB,eAAW,QAAQ,WAAW,WAAW,OAAO,IAAI;AACpD,WAAO;;AAET,SAAM,IAAI,MAAM,2CAA2C;;EAM7D,MAAM,SAAS;AAGf,MAFgB,sBAEJ,SAAS,SACnB,QAAO,WAAW,QAAQ,IAAI;AAGhC,QAAM,IAAI,MAAM,2CAA2C"}
@@ -0,0 +1,70 @@
1
+ //#region src/exec-time/exec-time.types.d.ts
2
+ /**
3
+ * Copyright 2026 ResQ
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Function type for reporting execution time data.
19
+ *
20
+ * @param {ExactTimeReportData} data - The execution time report data
21
+ * @returns {any} Can return any value (typically void)
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const customReporter: ReportFunction = (data) => {
26
+ * console.log(`Method took ${data.execTime}ms with args:`, data.args);
27
+ * metrics.timing('method.duration', data.execTime);
28
+ * };
29
+ * ```
30
+ */
31
+ type ReportFunction = (data: ExactTimeReportData) => unknown;
32
+ /**
33
+ * Data structure containing execution time information.
34
+ *
35
+ * @interface ExactTimeReportData
36
+ * @property {any[]} args - The arguments passed to the method
37
+ * @property {any} result - The return value of the method
38
+ * @property {number} execTime - The execution time in milliseconds
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const reportData: ExactTimeReportData = {
43
+ * args: [42, 'test'],
44
+ * result: 'success',
45
+ * execTime: 150
46
+ * };
47
+ * ```
48
+ */
49
+ interface ExactTimeReportData {
50
+ /** The arguments passed to the method */
51
+ args: unknown[];
52
+ /** The return value of the method */
53
+ result: unknown;
54
+ /** The execution time in milliseconds */
55
+ execTime: number;
56
+ }
57
+ /**
58
+ * Type for methods that can have their execution time reported.
59
+ *
60
+ * @template T - The type of the class containing the method
61
+ *
62
+ * @param {T} target - The class prototype
63
+ * @param {keyof T} propertyName - The name of the method
64
+ * @param {TypedPropertyDescriptor<any>} descriptor - The property descriptor
65
+ * @returns {any} The modified descriptor
66
+ */
67
+ type ExactTimeReportable<T> = (target: T, propertyName: keyof T, descriptor: TypedPropertyDescriptor<any>) => any;
68
+ //#endregion
69
+ export { ExactTimeReportData, ExactTimeReportable, ReportFunction };
70
+ //# sourceMappingURL=exec-time.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-time.types.d.ts","names":[],"sources":["../../src/exec-time/exec-time.types.ts"],"mappings":";;AA8BA;;;;;AAmBA;;;;;;;;;AAmBA;;;;;;;;;;;;;;AAAA,KAtCY,cAAA,IAAkB,IAAA,EAAM,mBAAA;;;;;;;;;;;;;;;;;;UAmBnB,mBAAA;;EAEf,IAAA;;EAEA,MAAA;;EAEA,QAAA;AAAA;;;;;;;;;;;KAaU,mBAAA,OACV,MAAA,EAAQ,CAAA,EACR,YAAA,QAAoB,CAAA,EACpB,UAAA,EAAY,uBAAA"}
File without changes
@@ -0,0 +1,4 @@
1
+ import { ExactTimeReportData, ExactTimeReportable, ReportFunction } from "./exec-time.types.js";
2
+ import { execTime } from "./exec-time.js";
3
+ import { execTimeFn } from "./exec-time.fn.js";
4
+ export { ExactTimeReportData, ExactTimeReportable, ReportFunction, execTime, execTimeFn };
@@ -0,0 +1,3 @@
1
+ import { execTimeFn } from "./exec-time.fn.js";
2
+ import { execTime } from "./exec-time.js";
3
+ export { execTime, execTimeFn };
@@ -0,0 +1,78 @@
1
+ //#region src/execute/execute.d.ts
2
+ /**
3
+ * Copyright 2026 ResQ
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * @fileoverview Execute decorator - automatically instantiates a class
19
+ * when it's decorated. Useful for singleton pattern implementation.
20
+ *
21
+ * @module @resq/typescript/decorators/execute
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * @selfExecute
26
+ * class SingletonService {
27
+ * private static instance: SingletonService;
28
+ *
29
+ * constructor() {
30
+ * if (SingletonService.instance) {
31
+ * return SingletonService.instance;
32
+ * }
33
+ * SingletonService.instance = this;
34
+ * }
35
+ *
36
+ * doSomething(): void {
37
+ * console.log('Doing something');
38
+ * }
39
+ * }
40
+ *
41
+ * // The class is automatically instantiated
42
+ * // SingletonService.doSomething(); // If methods were static
43
+ * ```
44
+ *
45
+ * @copyright Copyright (c) 2026 ResQ
46
+ * @license MIT
47
+ */
48
+ /**
49
+ * Class decorator that automatically instantiates the class when decorated.
50
+ * Creates an instance immediately and returns the constructor.
51
+ *
52
+ * @template T - The type of the class constructor
53
+ * @param {T} constructor - The class constructor
54
+ * @returns {T} The constructor (with instance created as side effect)
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * @selfExecute
59
+ * class AutoStartService {
60
+ * private timer: NodeJS.Timeout;
61
+ *
62
+ * constructor() {
63
+ * console.log('Service auto-started');
64
+ * this.timer = setInterval(() => this.tick(), 1000);
65
+ * }
66
+ *
67
+ * tick(): void {
68
+ * console.log('Tick');
69
+ * }
70
+ * }
71
+ *
72
+ * // Service is already running when this module loads
73
+ * ```
74
+ */
75
+ declare const selfExecute: <T extends new (...args: any[]) => object>(constructor: T) => T;
76
+ //#endregion
77
+ export { selfExecute };
78
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","names":[],"sources":["../../src/execute/execute.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,WAAA,qBAAiC,IAAA,oBAAwB,WAAA,EAAa,CAAA,KAAI,CAAA"}
@@ -0,0 +1,82 @@
1
+ //#region src/execute/execute.ts
2
+ /**
3
+ * Copyright 2026 ResQ
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * @fileoverview Execute decorator - automatically instantiates a class
19
+ * when it's decorated. Useful for singleton pattern implementation.
20
+ *
21
+ * @module @resq/typescript/decorators/execute
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * @selfExecute
26
+ * class SingletonService {
27
+ * private static instance: SingletonService;
28
+ *
29
+ * constructor() {
30
+ * if (SingletonService.instance) {
31
+ * return SingletonService.instance;
32
+ * }
33
+ * SingletonService.instance = this;
34
+ * }
35
+ *
36
+ * doSomething(): void {
37
+ * console.log('Doing something');
38
+ * }
39
+ * }
40
+ *
41
+ * // The class is automatically instantiated
42
+ * // SingletonService.doSomething(); // If methods were static
43
+ * ```
44
+ *
45
+ * @copyright Copyright (c) 2026 ResQ
46
+ * @license MIT
47
+ */
48
+ /**
49
+ * Class decorator that automatically instantiates the class when decorated.
50
+ * Creates an instance immediately and returns the constructor.
51
+ *
52
+ * @template T - The type of the class constructor
53
+ * @param {T} constructor - The class constructor
54
+ * @returns {T} The constructor (with instance created as side effect)
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * @selfExecute
59
+ * class AutoStartService {
60
+ * private timer: NodeJS.Timeout;
61
+ *
62
+ * constructor() {
63
+ * console.log('Service auto-started');
64
+ * this.timer = setInterval(() => this.tick(), 1000);
65
+ * }
66
+ *
67
+ * tick(): void {
68
+ * console.log('Tick');
69
+ * }
70
+ * }
71
+ *
72
+ * // Service is already running when this module loads
73
+ * ```
74
+ */
75
+ const selfExecute = (constructor) => {
76
+ new constructor();
77
+ return constructor;
78
+ };
79
+ //#endregion
80
+ export { selfExecute };
81
+
82
+ //# sourceMappingURL=execute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.js","names":[],"sources":["../../src/execute/execute.ts"],"sourcesContent":["/**\n * Copyright 2026 ResQ\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @fileoverview Execute decorator - automatically instantiates a class\n * when it's decorated. Useful for singleton pattern implementation.\n *\n * @module @resq/typescript/decorators/execute\n *\n * @example\n * ```typescript\n * @selfExecute\n * class SingletonService {\n * private static instance: SingletonService;\n *\n * constructor() {\n * if (SingletonService.instance) {\n * return SingletonService.instance;\n * }\n * SingletonService.instance = this;\n * }\n *\n * doSomething(): void {\n * console.log('Doing something');\n * }\n * }\n *\n * // The class is automatically instantiated\n * // SingletonService.doSomething(); // If methods were static\n * ```\n *\n * @copyright Copyright (c) 2026 ResQ\n * @license MIT\n */\n\n/**\n * Class decorator that automatically instantiates the class when decorated.\n * Creates an instance immediately and returns the constructor.\n *\n * @template T - The type of the class constructor\n * @param {T} constructor - The class constructor\n * @returns {T} The constructor (with instance created as side effect)\n *\n * @example\n * ```typescript\n * @selfExecute\n * class AutoStartService {\n * private timer: NodeJS.Timeout;\n *\n * constructor() {\n * console.log('Service auto-started');\n * this.timer = setInterval(() => this.tick(), 1000);\n * }\n *\n * tick(): void {\n * console.log('Tick');\n * }\n * }\n *\n * // Service is already running when this module loads\n * ```\n */\nexport const selfExecute = <T extends new (...args: any[]) => object>(constructor: T): T => {\n const _instance = new constructor();\n return constructor;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,eAAyD,gBAAsB;AACxE,KAAI,aAAa;AACnC,QAAO"}
@@ -0,0 +1,2 @@
1
+ import { selfExecute } from "./execute.js";
2
+ export { selfExecute };
@@ -0,0 +1,2 @@
1
+ import { selfExecute } from "./execute.js";
2
+ export { selfExecute };
package/lib/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { AsyncDecorator, AsyncMethod, Decorator, Method } from "./types.js";
2
+ import { AfterConfig, AfterFunc, AfterParams } from "./after/after.types.js";
3
+ import { after } from "./after/after.js";
4
+ import { BeforeConfig } from "./before/before.types.js";
5
+ import { before } from "./before/before.js";
6
+ import { bind } from "./bind/bind.js";
7
+ import { BindConfig } from "./bind/bind.types.js";
8
+ import { debounceFn } from "./debounce/debounce.fn.js";
9
+ import { delay } from "./delay/delay.js";
10
+ import { Delegatable } from "./delegate/delegate.types.js";
11
+ import { delegate } from "./delegate/delegate.js";
12
+ import { ExactTimeReportData, ExactTimeReportable, ReportFunction } from "./exec-time/exec-time.types.js";
13
+ import { execTime } from "./exec-time/exec-time.js";
14
+ import { execTimeFn } from "./exec-time/exec-time.fn.js";
15
+ import { selfExecute } from "./execute/execute.js";
16
+ import { Cache, KeyResolver, Memoizable, MemoizeConfig } from "./memoize/memoize.types.js";
17
+ import { memoize } from "./memoize/memoize.js";
18
+ import { AsyncCache, AsyncMemoizable, AsyncMemoizeConfig } from "./memoize-async/memoize-async.types.js";
19
+ import { memoizeAsyncFn } from "./memoize-async/memoize-async.fn.js";
20
+ import { memoizeAsync } from "./memoize-async/memoize-async.js";
21
+ import { observe } from "./observer/observer.js";
22
+ import { ObserverCallback } from "./observer/observer.types.js";
23
+ import { RateLimitAsyncCounter, RateLimitConfigs, RateLimitCounter, RateLimitable } from "./rate-limit/rate-limit.types.js";
24
+ import { rateLimit } from "./rate-limit/rate-limit.js";
25
+ import { SimpleRateLimitCounter } from "./rate-limit/simple-rate-limit-counter.js";
26
+ import { readonly } from "./readonly/readonly.js";
27
+ import { Readonlyable } from "./readonly/readonly.types.js";
28
+ import { throttle } from "./throttle/throttle.js";
29
+ import { throttleAsync } from "./throttle-async/throttle-async.js";
30
+ export { AfterConfig, AfterFunc, AfterParams, AsyncCache, AsyncDecorator, AsyncMemoizable, AsyncMemoizeConfig, AsyncMethod, BeforeConfig, BindConfig, Cache, Decorator, Delegatable, ExactTimeReportData, ExactTimeReportable, KeyResolver, Memoizable, MemoizeConfig, Method, ObserverCallback, RateLimitAsyncCounter, RateLimitConfigs, RateLimitCounter, RateLimitable, Readonlyable, ReportFunction, SimpleRateLimitCounter, after, before, bind, debounceFn, delay, delegate, execTime, execTimeFn, memoize, memoizeAsync, memoizeAsyncFn, observe, rateLimit, readonly, selfExecute, throttle, throttleAsync };
package/lib/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { after } from "./after/after.js";
2
+ import { before } from "./before/before.js";
3
+ import { bind } from "./bind/bind.js";
4
+ import { debounceFn } from "./debounce/debounce.fn.js";
5
+ import { delay } from "./delay/delay.js";
6
+ import { delegate } from "./delegate/delegate.js";
7
+ import { execTimeFn } from "./exec-time/exec-time.fn.js";
8
+ import { execTime } from "./exec-time/exec-time.js";
9
+ import { selfExecute } from "./execute/execute.js";
10
+ import { memoize } from "./memoize/memoize.js";
11
+ import { memoizeAsyncFn } from "./memoize-async/memoize-async.fn.js";
12
+ import { memoizeAsync } from "./memoize-async/memoize-async.js";
13
+ import { observe } from "./observer/observer.js";
14
+ import { SimpleRateLimitCounter } from "./rate-limit/simple-rate-limit-counter.js";
15
+ import { rateLimit } from "./rate-limit/rate-limit.js";
16
+ import { readonly } from "./readonly/readonly.js";
17
+ import { throttle } from "./throttle/throttle.js";
18
+ import { throttleAsync } from "./throttle-async/throttle-async.js";
19
+ export { SimpleRateLimitCounter, after, before, bind, debounceFn, delay, delegate, execTime, execTimeFn, memoize, memoizeAsync, memoizeAsyncFn, observe, rateLimit, readonly, selfExecute, throttle, throttleAsync };
@@ -0,0 +1,3 @@
1
+ import { Cache, KeyResolver, Memoizable, MemoizeConfig } from "./memoize.types.js";
2
+ import { memoize } from "./memoize.js";
3
+ export { Cache, KeyResolver, Memoizable, MemoizeConfig, memoize };
@@ -0,0 +1,2 @@
1
+ import { memoize } from "./memoize.js";
2
+ export { memoize };