Skip to content

Commit 50ea8d5

Browse files
committed
Add Int.equal, Int.compare
1 parent b534e28 commit 50ea8d5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Core__Int.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
import * as Pervasives from "rescript/lib/es6/pervasives.js";
44
import * as Core__Array from "./Core__Array.mjs";
55

6+
function equal(a, b) {
7+
return a === b;
8+
}
9+
10+
function compare(a, b) {
11+
return a - b | 0;
12+
}
13+
614
function fromString(radix, x) {
715
var maybeInt = radix !== undefined ? parseInt(x, radix) : parseInt(x);
816
if (isNaN(maybeInt) || maybeInt > 2147483647 || maybeInt < -2147483648) {
@@ -54,6 +62,8 @@ var Constants = {
5462

5563
export {
5664
Constants ,
65+
equal ,
66+
compare ,
5767
fromString ,
5868
range ,
5969
rangeWithOptions ,

src/Core__Int.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ module Constants = {
33
@inline let maxValue = 2147483647
44
}
55

6+
let equal = (a: int, b: int) => a === b
7+
8+
let compare = (a, b) => a - b
9+
610
@send external toExponential: int => string = "toExponential"
711
@send external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential"
812

src/Core__Int.resi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ module Constants: {
5656
let maxValue: int
5757
}
5858

59+
let equal: (int, int) => bool
60+
61+
let compare: (int, int) => int
62+
5963
/**
6064
`toExponential(n)` return a `string` representing the given value in exponential
6165
notation.

0 commit comments

Comments
 (0)