declare namespace TransferUtil { /** * 字符串转成base64编码 * @param { String } str 字符串 * @example * base64Encode('nanshen') => bmFuc2hlbg== */ function base64Encode(str: string): string; /** * base64解码成字符串 * @param { String } str base64字符串 * @example * base64Decode('bmFuc2hlbg==') => nanshen */ function base64Decode(str: string): string; /** * 将文件转成base64 * @param file 文件 * @example * const fn = async () => { * const newFile = new File(['text1', 'text2'], 'test.txt', {type: 'text/plain'}) * const data = await getBase64ByFile(newFile) * console.log(data); => data:text/plain;base64,dGV4dDF0ZXh0Mg== * } * fn() */ function getBase64ByFile(file: any): Promise | undefined; /** * 将base64转成文件 * @param file 文件 * @example * getFileByBase64('data:text/plain;base64,dGV4dDF0ZXh0Mg==','test.txt') => new File(['text1', 'text2'], 'test.txt', {type: 'text/plain'}) */ function getFileByBase64(base64: string, filename: string): File | undefined; /** * base64转blob流 * @param base64 base64字符串 * @example * getBlobByBase64('data:text/plain;base64,dGV4dDF0ZXh0Mg==') => new Blob(['text1', 'text2'], {type : 'text/plain'}) */ function getBlobByBase64(base64: string): Blob | undefined; /** * blob流转换为base64 * @param blob blob流 * @example * const fn = async () => { * const newBlob = new Blob(['text1', 'text2'], {type : 'text/plain'}) * const data = await blobToDataURI(newBlob) * console.log(data); => data:text/plain;base64,dGV4dDF0ZXh0Mg== * } * fn() */ function blobToDataURI(blob: any): Promise | undefined; /** * html编码(转义) * @param { String } text 需要转义的字符串 * @param { Boolean } useDom 转换方法选择 * @example * htmlEncode('

你好

') => <p>你好</p> */ function htmlEncode(text: string, useDom?: boolean): string; /** * html解码(反转义) * @param { String } text 需要反转义的字符串 * @param { Boolean } useDom 转换方法选择 * @example * htmlDecode('<p>你好</p>') =>

你好

*/ function htmlDecode(text: string, useDom?: boolean): string; /** * 现金额转大写 * @param n 阿拉伯数字 * @example * digitUppercase(1) => 壹元整 */ function digitUppercase(n: number): string; /** * 数字转大写 * @param n 阿拉伯数字 * @example * digitUppercase(1) => 一 */ function toChinesNum(num: number): string; /** * 数字大于千万亿加单位 * @param value 阿拉伯数字 * @param index 保留几位小数(默认为2) * @example * numPlusUnit(1213) => 1.21千 */ function numPlusUnit(value: number, index?: number): string; } export default TransferUtil;