bloodyowl/rescript-js

Int.fromStringWithRadix (parseInt) missing

Closed this issue · 3 comments

The current binding has a fixed argument for the radix:

@val external fromString: (string, ~radix: @as(json`10`) _) => float = "parseInt"

You have Float.parseIntWithRadix for that. The rationale behind putting it there is that it might return NaN which belongs to floats.

I see Int.fromString returns an option<int>; would that be an option for Int.fromStringWithRadix?

I guess having a slight runtime on this wouldn't hurt given how often people can use it. Would you be able to send a PR?