@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
20 lines • 656 B
JavaScript
/**
* @module Middleware
*/
import {} from "../../../middleware/contracts/_module.js";
import {} from "../../../utilities/_module.js";
/**
* IMPORT_PATH: `@daiso-tech/core/middleware`
* @group Implementations
*/
export function enhanceFactory(use) {
return (obj, field, middlewares) => {
const fn = obj[field];
if (typeof fn !== "function") {
throw new TypeError(`Cannot enhance ${String(field)} because it is not a function`);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
obj[field] = use(fn.bind(obj), middlewares);
};
}
//# sourceMappingURL=enhance-factory.js.map