Skip to content

Commit

Permalink
Replace deprecated String.prototype.substr()
Browse files Browse the repository at this point in the history
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot committed Mar 24, 2022
1 parent f9629ac commit 4833937
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 4833937

Please sign in to comment.