Skip to content

Commit

Permalink
Merge pull request #390 from CommanderRoot/refactor/rm-deprecated-substr
Browse files Browse the repository at this point in the history
Replace deprecated String.prototype.substr()
  • Loading branch information
ChristophWurst authored May 30, 2022
2 parents 30c42b5 + 4833937 commit 19d3b10
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/humanfilesize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export function formatFileSize(size: number, skipSmallSizes: boolean = false): s
}
if (order < 2) {
relativeSize = parseFloat(relativeSize).toFixed(0);
} else if (relativeSize.substr(relativeSize.length - 2, 2) === '.0') {
relativeSize = relativeSize.substr(0, relativeSize.length - 2);
} else if (relativeSize.slice(-2) === '.0') {
relativeSize = relativeSize.slice(0, -2);
} else {
relativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale());
}
Expand Down

0 comments on commit 19d3b10

Please sign in to comment.