Skip to content

Commit 4944696

Browse files
committed
👍 Allow non async function as a callback
1 parent 6937ba4 commit 4944696

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

denops_std/anonymous/mod.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type Identifier = string;
1616
/**
1717
* Anonymous function callback
1818
*/
19-
export type Callback = (...args: unknown[]) => Promise<unknown>;
19+
export type Callback = (...args: unknown[]) => Promise<unknown> | unknown;
2020

2121
/**
2222
* Add anonymous functions as a denops API and return the identifiers
@@ -27,7 +27,9 @@ export function add<N extends number>(
2727
): TupleOf<Identifier, N> {
2828
return callbacks.map((callback) => {
2929
const id = makeid();
30-
denops.dispatcher[id] = callback;
30+
denops.dispatcher[id] = async (...args: unknown[]) => {
31+
return await callback(...args);
32+
};
3133
return id;
3234
// deno-lint-ignore no-explicit-any
3335
}) as any;

0 commit comments

Comments
 (0)