Skip to content

Commit

Permalink
feat: overload getCharacterLength
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangpaopao0609 committed Feb 3, 2025
1 parent 4874cda commit cbcd9db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@ module.exports = {
'comma-dangle': 0,
'no-shadow': 0,
'object-curly-newline': 0,
// 避免 `eslint` 对于 `typescript` 函数重载的误报
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error'
},
};
2 changes: 2 additions & 0 deletions js/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export function getFlexGapPolyFill() {
* @param maxCharacter 规定最大字符串长度
* @returns 当没有传入maxCharacter时返回字符串字符长度,当传入maxCharacter时返回截取之后的字符串和长度。
*/
export function getCharacterLength(str: string): number;
export function getCharacterLength(str: string, maxCharacter?: number): { length: number; characters: string }
export function getCharacterLength(str: string, maxCharacter?: number) {
const hasMaxCharacter = isNumber(maxCharacter);
if (!str || str.length === 0) {
Expand Down

0 comments on commit cbcd9db

Please sign in to comment.