@@ -72,40 +72,6 @@ const isOptionsWithDataIndexArgument = (
72
72
*
73
73
* ```
74
74
*/
75
- /* const makeIdempotent = <Func extends AnyFunction>(
76
- fn: Func,
77
- options: ItempotentFunctionOptions<Parameters<Func>>,
78
- thisArg: Handler
79
- ): ((...args: Parameters<Func>) => ReturnType<Func>) => {
80
- const { persistenceStore, config } = options;
81
- const idempotencyConfig = config ? config : new IdempotencyConfig({});
82
-
83
- if (!idempotencyConfig.isEnabled()) return fn;
84
-
85
- return (...args: Parameters<Func>): ReturnType<Func> => {
86
- let functionPayloadToBeHashed;
87
-
88
- if (isFnHandler(fn, args)) {
89
- idempotencyConfig.registerLambdaContext(args[1]);
90
- functionPayloadToBeHashed = args[0];
91
- } else {
92
- if (isOptionsWithDataIndexArgument(options)) {
93
- functionPayloadToBeHashed = args[options.dataIndexArgument];
94
- } else {
95
- functionPayloadToBeHashed = args[0];
96
- }
97
- }
98
-
99
- return new IdempotencyHandler({
100
- functionToMakeIdempotent: fn,
101
- idempotencyConfig: idempotencyConfig,
102
- persistenceStore: persistenceStore,
103
- functionArguments: args,
104
- functionPayloadToBeHashed,
105
- thisArg,
106
- }).handle() as ReturnType<Func>;
107
- };
108
- }; */
109
75
// eslint-disable-next-line func-style
110
76
function makeIdempotent < Func extends AnyFunction > (
111
77
fn : Func ,
@@ -116,7 +82,7 @@ function makeIdempotent<Func extends AnyFunction>(
116
82
117
83
if ( ! idempotencyConfig . isEnabled ( ) ) return fn ;
118
84
119
- return function ( ...args : Parameters < Func > ) : ReturnType < Func > {
85
+ return function ( this : Handler , ...args : Parameters < Func > ) : ReturnType < Func > {
120
86
let functionPayloadToBeHashed ;
121
87
122
88
if ( isFnHandler ( fn , args ) ) {
@@ -136,7 +102,6 @@ function makeIdempotent<Func extends AnyFunction>(
136
102
persistenceStore : persistenceStore ,
137
103
functionArguments : args ,
138
104
functionPayloadToBeHashed,
139
- // @ts -expect-error abc
140
105
thisArg : this ,
141
106
} ) . handle ( ) as ReturnType < Func > ;
142
107
} ;
0 commit comments