UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

16 lines (13 loc) 368 B
import { toNumber } from './toNumber.mjs'; function toFinite(value) { if (!value) { return value === 0 ? value : 0; } value = toNumber(value); if (value === Infinity || value === -Infinity) { const sign = value < 0 ? -1 : 1; return sign * Number.MAX_VALUE; } return value === value ? value : 0; } export { toFinite };