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

feat: added G.isFinite, G.isInfinite #109

Open JUSTIVE opened 5 months ago

JUSTIVE commented 5 months ago

resolves #108

JUSTIVE commented 5 months ago

Attempted with rescript with gentype, but Js.Float.isFinite turned into $$isFinite. I'm not sure why, so currently it's implemented with js and type definitions. if anyone knows reason why, please let me know.

JUSTIVE commented 5 months ago

https://forum.rescript-lang.org/t/prefix-from-build-output/5115/2?u=justive

$$ appeared because of the ambiguity of the isFinite, which is globally available on the js side.

motherthestate commented 5 months ago

@JUSTIVE Hey, thanks for the PR :). Looking at the typing maybe replicating the isNumber type would be more practical, since Number.isFinite is typed isFinite(number: unknown) by default, we would just extend it with a type predicate.

export declare function isFinite<A>(
  value: A | number,
): value is Guard<A, number>

Edit: @JUSTIVE Also I don't know how likely these PR are to be merged, seeing how many are racking up and staying open. The last merge seems to date back to 2022.

JUSTIVE commented 5 months ago

I'm also not sure when @mobily will be back, but I believe he will, as he said on #93. As a daily ts-belt user, I really love this library, and hope to keep maintained.

just updated the type as you said, thanks for the reply.