You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section currently covers a small subset of available modules relevant for ReScript development.
3
+
ReScript ships 3 modules in its standard library.
4
4
5
-
The API documentation is still under revision and will be improved in the future.
5
+
-[Js](api/js): bindings for all your familiar JavaScript APIs.
6
+
-[Belt](api/belt): extra collections and helpers not available in JavaScript.
7
+
-[Dom](api/dom): Dom related types and modules.
6
8
7
-
**List of important modules:**
9
+
Usage heuristics:
8
10
9
-
-[Js](api/js): Bindings for Common Browser APIs
10
-
-[Belt](api/belt): The ReScript Standard Library
11
-
-[Dom](api/dom): Dom related types and modules
11
+
- Default to using the `Js` module. Most of the APIs in it are runtime-free and compile down to clean, readable JavaScript, which is our priority.
12
+
- For other APIs that aren't available in regular JavaScript (and thus don't exist in our `Js` bindings), use Belt. For example, prefer `Js.Array2` over `Belt.Array`.
13
+
- The `Dom` module contains our standardized types used by various userland DOM bindings. Due to the complexity of DOM, we don't mind that you ignore this module and build your application-specific DOM bindings.
14
+
15
+
**Note**: we do not recommend other userland standard library alternatives (unless it's DOM bindings). These cause confusion and split points for the community.
It is meant as a zero-abstraction interop layer and directly exposes
12
-
JavaScript functions as they are, even when their behavior should be considered unsafe
13
-
(e.g. modifying an array in place using [Js.Array.push](js/array#push)).
14
-
15
-
Therefore, when a corresponding module is available in the [Belt](belt) standard library,
16
-
it is recommended to use the Belt version rather than the Js version.
17
-
For example, you should prefer [Belt.Array](belt/array)
18
-
to [Js.Array](js/array)
19
-
and [Belt.Map.String](belt/map-string)
20
-
to [Js.Dict](js/dict).
11
+
It is meant as a zero-abstraction interop layer and directly exposes JavaScript functions as they are. If you can find your API in this module, prefer this over an equivalent Belt helper. For example, prefer [Js.Array2](js/array2) over [Belt.Array](belt/array)
21
12
22
13
## Argument Order
23
14
@@ -34,15 +25,15 @@ In the meantime, there are several options for dealing with the data-last APIs:
34
25
```res example
35
26
/* Js.String (data-last API used with pipe last operator) */
36
27
Js.log("2019-11-10" |> Js.String.split("-"))
37
-
Js.log("Reason" |> Js.String.startsWith("Re"))
28
+
Js.log("ReScript" |> Js.String.startsWith("Re"))
38
29
39
30
/* Js.String (data-last API used with pipe first operator) */
40
31
Js.log("2019-11-10"->Js.String.split("-", _))
41
-
Js.log("Reason"->Js.String.startsWith("Re", _))
32
+
Js.log("ReScript"->Js.String.startsWith("Re", _))
42
33
43
34
/* Js.String (data-last API used without any piping) */
This section currently covers a very small subset of available modules relevant
4
-
for JavaScript development.
5
-
6
-
Please note that most of the API documentation is
7
-
still under revision and will be improved in the future.
3
+
We ship 3 modules in our standard library.
8
4
9
-
**List of important modules:**
5
+
-[Js](api/js): bindings for all your familiar JavaScript APIs.
6
+
-[Belt](api/belt): extra collections and helpers not available in JavaScript.
7
+
-[Dom](api/dom): Dom related types and modules.
10
8
11
-
-[Belt](api/belt): The Reason Standard Library for the Web
12
-
-[Js](api/js): Bindings for Common Browser APIs
13
-
-[Dom](api/dom): Dom related types and modules
9
+
Usage heuristics:
10
+
11
+
- Default to using the `Js` module. Most of the APIs in it are runtime-free and compile down to clean, readable JavaScript, which is our priority.
12
+
- For other APIs that aren't available in regular JavaScript (and thus don't exist in our `Js` bindings), use Belt. For example, prefer `Js.Array2` over `Belt.Array`.
13
+
- The `Dom` module contains our standardized types used by various userland DOM bindings. Due to the complexity of DOM, we don't mind that you ignore this module and build your application-specific DOM bindings.
14
+
15
+
**Note**: we do not recommend other userland standard library alternatives (unless it's DOM bindings). These cause confusion and split points for the community.
It is meant as a zero-abstraction interop layer and directly exposes
12
-
JavaScript functions as they are, even when their behavior should be considered unsafe
13
-
(e.g. modifying an array in place using [Js.Array.push](./js/array#push)).
14
-
15
-
Therefore, when a corresponding module is available in the [Belt](./belt) standard library,
16
-
it is recommended to use the Belt version rather than the Js version.
17
-
For example, you should prefer [Belt.Array](./belt/array)
18
-
to [Js.Array](./js/array)
19
-
and [Belt.Map.String](./belt/map-string)
20
-
to [Js.Dict](./js/dict).
11
+
It is meant as a zero-abstraction interop layer and directly exposes JavaScript functions as they are. If you can find your API in this module, prefer this over an equivalent Belt helper. For example, prefer [Js.Array2](js/array2) over [Belt.Array](belt/array)
21
12
22
13
## Argument Order
23
14
@@ -34,15 +25,15 @@ In the meantime, there are several options for dealing with the data-last APIs:
34
25
```re example
35
26
/* Js.String (data-last API used with pipe last operator) */
36
27
Js.log("2019-11-10" |> Js.String.split("-"));
37
-
Js.log("Reason" |> Js.String.startsWith("Re"));
28
+
Js.log("ReScript" |> Js.String.startsWith("Re"));
38
29
39
30
/* Js.String (data-last API used with pipe first operator) */
0 commit comments