mobily / ts-belt

🔧 Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.08k stars 30 forks source link

Proposal: G.isFinite #108

Open motherthestate opened 5 months ago

motherthestate commented 5 months ago

Since isNumber currently only checks if the value is a number or infinity.

function px (value: number | string) {
  if (G.isNumber(value)) return `${value}px`
  return px
}

px(1/0) // "Infinitypx"

// Proposal:
G.isFinite(1/0) // false

To be clear this does not actually add a new type guard since infinity is a number in javascript and typescript does not make the distinction.

JUSTIVE commented 5 months ago

Hi. I made a PR to resolve this issue. please have a look and let me know if it's right.