Skip to content

Commit 8f78206

Browse files
committed
allow fallback on async
1 parent 434b979 commit 8f78206

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/Instance.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ export class Marked<ParserOutput = string, RendererOutput = string> {
217217
} else {
218218
// @ts-expect-error cannot type hook function dynamically
219219
hooks[hooksProp] = (...args: unknown[]) => {
220+
if (this.defaults.async) {
221+
return Promise.resolve(hooksFunc.apply(hooks, args)).then(ret => {
222+
if (ret === false) {
223+
ret = prevHook.apply(hooks, args);
224+
}
225+
return ret;
226+
});
227+
}
228+
220229
let ret = hooksFunc.apply(hooks, args);
221230
if (ret === false) {
222231
ret = prevHook.apply(hooks, args);

0 commit comments

Comments
 (0)