Skip to content

Commit

Permalink
fix: decorator calling with array of array (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
onhate authored Aug 30, 2023
1 parent 187580c commit 0586002
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inbatches",
"version": "0.0.8",
"version": "0.0.9",
"private": false,
"license": "MIT",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getInstanceBatcher<I, K, V>(instance: I, property: string, descriptor:
instance[holder] = instance[holder] ?? new Map<string, MethodBatcher<I, K, V>>();

// check if the instance already has a method matcher for this specific method
if (instance[holder].has(property)) return instance[holder].get(property);
if (instance[holder].has(property)) return instance[holder].get(property) as MethodBatcher<I, K, V>;

// otherwise, create a new batcher and store it in the instance batchers holder
const batcher = new MethodBatcher<I, K, V>(instance, descriptor, options);
Expand All @@ -36,9 +36,9 @@ function getInstanceBatcher<I, K, V>(instance: I, property: string, descriptor:
export function InBatches<K, V>(options?: BatcherOptions) {
return function (_: any, property: string, descriptor: PropertyDescriptor) {
const method = descriptor.value;
descriptor.value = function (...args: any[]) {
descriptor.value = function (key: K) {
const batcher = getInstanceBatcher<any, K, V>(this, property, method, options);
return batcher.enqueue(args);
return batcher.enqueue(key);
};

return descriptor;
Expand Down

0 comments on commit 0586002

Please sign in to comment.