requirefresh
Version:
Require a file without adding it into the require cache
31 lines • 1.52 kB
TypeScript
/**
* Require Fresh Callback in typical errback style.
* @param error if the `require` call threw, this is its error
* @param result if the `require` call performed succesfully, this is its result
*/
export type Errback = (error: Error | undefined, result: any) => any;
/**
* Require the path without any caching.
* @param path the path to require
* @returns the result of the `require` call
* @throws note that the `require` call may throw if something went wrong requiring the path
*/
export declare function requireFresh(path: string): any;
export default requireFresh;
/**
* Require the path without any caching, but catch errors into the callback.
* Error cannot be returned because what if the module intended to RETURN (not throw) an error, hence why callback is used, as it can differentiate between returned and thrown errors.
* @param path the path to require
* @param next the callback
* @returns {void}
*/
export declare function requireFreshCallback(path: string, next: Errback): void;
export declare const requireFreshSafe: typeof requireFreshCallback;
/**
* Require the path without any caching, but catch errors into the callback.
* Error cannot be returned because what if the module intended to RETURN (not throw) an error, hence why promise is used, as it can differentiate between returned and thrown errors.
* @param path the path to require
* @returns {void}
*/
export declare function requireFreshPromise(path: string): Promise<unknown>;
//# sourceMappingURL=index.d.ts.map