Skip to content

Commit 17f0d29

Browse files
glennslzth
authored andcommitted
feat: add Ordering module
1 parent 82afba1 commit 17f0d29

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/Core__Ordering.mjs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
function isLess(ord) {
5+
return ord < 0;
6+
}
7+
8+
function isEqual(ord) {
9+
return ord === 0;
10+
}
11+
12+
function isGreater(ord) {
13+
return ord > 0;
14+
}
15+
16+
function invert(ord) {
17+
return - ord;
18+
}
19+
20+
function fromInt(n) {
21+
if (n < 0) {
22+
return -1;
23+
} else if (n > 0) {
24+
return 1;
25+
} else {
26+
return 0;
27+
}
28+
}
29+
30+
var less = -1;
31+
32+
var equal = 0;
33+
34+
var greater = 1;
35+
36+
export {
37+
less ,
38+
equal ,
39+
greater ,
40+
isLess ,
41+
isEqual ,
42+
isGreater ,
43+
invert ,
44+
fromInt ,
45+
}
46+
/* No side effect */

src/Core__Ordering.res

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type t = float
2+
3+
let less = -1.
4+
let equal = 0.
5+
let greater = 1.
6+
7+
let isLess = ord => ord < equal
8+
let isEqual = ord => ord == equal
9+
let isGreater = ord => ord > equal
10+
11+
let invert = ord => -.ord
12+
13+
let fromInt = n => n < 0 ? less : n > 0 ? greater : equal

src/RescriptCore.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var Nullable;
2828

2929
var $$Object;
3030

31+
var Ordering;
32+
3133
var $$Promise;
3234

3335
var $$RegExp;
@@ -110,6 +112,7 @@ export {
110112
Null ,
111113
Nullable ,
112114
$$Object ,
115+
Ordering ,
113116
$$Promise ,
114117
$$RegExp ,
115118
$$String ,

src/RescriptCore.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Math = Core__Math
1313
module Null = Core__Null
1414
module Nullable = Core__Nullable
1515
module Object = Core__Object
16+
module Ordering = Core__Ordering
1617
module Promise = Core__Promise
1718
module RegExp = Core__RegExp
1819
module String = Core__String

0 commit comments

Comments
 (0)