src/helpers/lazyFunctionRequire.js

Summary

Maintainability
A
0 mins
Test Coverage
/*
 * Function that can be used to make require lazy if the default export is a function.
 */
export default function lazyFunctionRequire(fn) {
    return (id) => (...args) => {
        const mod = fn(id);
        return mod.__esModule ? mod.default(...args) : mod(...args);
    };
}