t-comm
Version:
专业、稳定、纯粹的工具库
20 lines (19 loc) • 700 B
TypeScript
/**
* 以 Promise 或者 Callback 的方式加载 js 文件,取决于是否传递 Callback
* @param {string} url js文件路径
* @param {function} [cb] 回调
* @returns {Promise<number>} promise
* @example
* ```ts
* // 1. Promise 方式
* await loaderUnity('https://example.com/lib.js');
*
* // 2. Callback 方式
* loaderUnity('https://example.com/lib.js', (err) => {
* if (err) return console.error(err);
* console.log('loaded');
* });
* ```
*/
export declare const loaderUnity: (source: string, cb?: Function, ...args: Array<any>) => void | Promise<unknown>;
export declare const loader: (source: string, cb?: Function, ...args: Array<any>) => void | Promise<unknown>;