import { AsyncHooks } from "@daiso-tech/core/async";
import { dynamic, fallback } from "@daiso-tech/core/utilities";
await new AsyncHooks(
(a: number, b: number) => a / b,
[
// You pass callback function where you get access to the function arguments and context.
// The callback function must return a middleware.
dynamic((_args, _context) =>
fallback({
fallbackValue: 1,
}),
),
],
).invoke(1, 0);
The
dynamic
is wrapper middleware that allows configuration of other middlewares dynamically based on the function arguments and context.IMPORT_PATH:
"@daiso-tech/core/async"