d-utils
Version:
d-utils
13 lines (12 loc) • 567 B
TypeScript
/**
* @description 计算字符串长度 isStrict为true的时候 返回一个字符串的长度,汉字算2个字符长度
* @param { String } str 要计算的字符串
* @param { Boolean } isStrict true 返回一个字符串的长度,汉字算2个字符长度; false 直接返回长度
* @return { Number } 返回字符串长度
* @example
* const str = 'd-utils库'
* console(calcStrLength(str))
* console(calcStrLength(str, true))
*/
declare function calcStrLength(str: string, isStrict?: boolean): number;
export default calcStrLength;