t-comm
Version:
专业、稳定、纯粹的工具库
17 lines (16 loc) • 500 B
TypeScript
/// <reference types="node" />
import type * as UtilType from 'util';
/**
* 获取 Node.js 的 util 模块
* 这样可以避免在浏览器环境中直接导入 util 模块导致的错误
* @returns util 模块
* @example
* ```ts
* const util = getUtil();
* console.log(util.format('%s + %s = %s', 1, 2, 3)); // '1 + 2 = 3'
*
* const promisify = util.promisify(fs.readFile);
* const data = await promisify('./a.txt', 'utf-8');
* ```
*/
export declare function getUtil(): typeof UtilType;