Use Number.parseInt/parseFloat/isNaN/isFinite instead of globals (S7773)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,8 +22,8 @@ export default function abbreviateNumber(totalSeconds) {
|
||||
let result = "";
|
||||
let symbols = ["d", "h", "m", "s"];
|
||||
|
||||
totalSeconds = parseInt(totalSeconds);
|
||||
if (!isNaN(totalSeconds)) {
|
||||
totalSeconds = Number.parseInt(totalSeconds);
|
||||
if (!Number.isNaN(totalSeconds)) {
|
||||
seconds = totalSeconds % 60;
|
||||
minutes = (Math.floor(totalSeconds - seconds) / 60) % 60;
|
||||
hours = Math.floor(totalSeconds / 3600) % 24;
|
||||
|
||||
@@ -231,7 +231,7 @@ export function getXIndex(data, xValue) {
|
||||
* or null if the input is NaN.
|
||||
*/
|
||||
export function formatTime(seconds) {
|
||||
if (!isNaN(seconds)) {
|
||||
if (!Number.isNaN(Number(seconds))) {
|
||||
const remainingSeconds = seconds % 60;
|
||||
const minutes = (Math.floor(seconds - remainingSeconds) / 60) % 60;
|
||||
const hours = Math.floor(seconds / 3600) % 24;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
export function sortNumEngZhtw(data) {
|
||||
return data.sort((a, b) => {
|
||||
const isANumber = !isNaN(parseFloat(a)) && isFinite(a);
|
||||
const isBNumber = !isNaN(parseFloat(b)) && isFinite(b);
|
||||
const isANumber = !Number.isNaN(Number.parseFloat(a)) && Number.isFinite(Number(a));
|
||||
const isBNumber = !Number.isNaN(Number.parseFloat(b)) && Number.isFinite(Number(b));
|
||||
|
||||
if (isANumber && isBNumber) return parseFloat(a) - parseFloat(b);
|
||||
if (isANumber && isBNumber) return Number.parseFloat(a) - Number.parseFloat(b);
|
||||
|
||||
if (isANumber) return -1;
|
||||
if (isBNumber) return 1;
|
||||
@@ -40,10 +40,10 @@ export function sortNumEngZhtw(data) {
|
||||
* @returns {number} Negative if a < b, positive if a > b, zero if equal.
|
||||
*/
|
||||
export function sortNumEngZhtwForFilter(a, b) {
|
||||
const isANumber = !isNaN(parseFloat(a)) && isFinite(a);
|
||||
const isBNumber = !isNaN(parseFloat(b)) && isFinite(b);
|
||||
const isANumber = !Number.isNaN(Number.parseFloat(a)) && Number.isFinite(Number(a));
|
||||
const isBNumber = !Number.isNaN(Number.parseFloat(b)) && Number.isFinite(Number(b));
|
||||
|
||||
if (isANumber && isBNumber) return parseFloat(a) - parseFloat(b);
|
||||
if (isANumber && isBNumber) return Number.parseFloat(a) - Number.parseFloat(b);
|
||||
|
||||
if (isANumber) return -1;
|
||||
if (isBNumber) return 1;
|
||||
|
||||
Reference in New Issue
Block a user