File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Next version
4
4
5
+ - Add ` Nullable.isNullable ` function. https://github.com/rescript-association/rescript-core/pull/227
5
6
- Remove some deps to Belt, Pervasives and Js. https://github.com/rescript-association/rescript-core/pull/226/commits
6
7
7
8
## 1.3.0
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ external null: t<'a> = "#null"
7
7
8
8
external undefined : t <'a > = "#undefined"
9
9
10
+ external isNullable : t <'a > => bool = "#is_nullable"
11
+
10
12
external make : 'a => t <'a > = "%identity"
11
13
12
14
external toOption : t <'a > => option <'a > = "#nullable_to_opt"
Original file line number Diff line number Diff line change @@ -38,6 +38,27 @@ Console.log(undefined) // Logs `undefined` to the console.
38
38
*/
39
39
external undefined: t<'a> = "#undefined"
40
40
41
+ /**
42
+ `isNullable(a)` returns `true` if `a` is null or undefined, `false` otherwise.
43
+
44
+ ## Examples
45
+
46
+ ```rescript
47
+ let myStr = "Hello"
48
+ let asNullable = myStr->Nullable.make
49
+
50
+ // Can't do the below because we're now forced to check for nullability
51
+ // myStr == asNullable
52
+
53
+ // Check if asNullable is not null or undefined
54
+ switch asNullable->Nullable.isNullable {
55
+ | true => assert(false)
56
+ | false => assert(true)
57
+ }
58
+ ```
59
+ */
60
+ external isNullable: t<'a> => bool = "#is_nullable"
61
+
41
62
/**
42
63
Creates a new nullable value from the provided value.
43
64
This means the compiler will enforce null checks for the new value.
You can’t perform that action at this time.
0 commit comments