Skip to content

Commit

Permalink
fix(utils): default error (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtinghang authored Oct 6, 2023
1 parent a70a1cd commit 6ff2ab3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,21 @@ export const generateID = (): string => {
return `_${Math.random().toString(36).substr(2, 9)}`;
};

export interface SizeFormatterOptions {
withUnit?: boolean;
withByte?: boolean;
trimZero?: boolean;
convertNum?: number
}

// https://github.com/n9e/fe-v5/issues/72 修改 withByte 默认为 false
export const sizeFormatter = (
val,
fixedCount = 2,
{ withUnit = true, withByte = false, trimZero = false, convertNum = 1024 } = {
withUnit: true,
withByte: false,
trimZero: false,
convertNum: 1024 | 1000,
},
options?: SizeFormatterOptions,
) => {
const size = val ? Number(val) : 0;
const { withUnit = true, withByte = false, trimZero = false, convertNum = 1024 } = options || {}
let result;
let unit = '';

Expand Down

0 comments on commit 6ff2ab3

Please sign in to comment.