[!NOTE] This project is archived as it's now included as the standard library in ReScript 12 (https://rescript-lang.org/blog/release-12-0-0#improved-standard-library)
Bindings to the JS standard library
This is an alternative library to the default Js module.
Main differences:
Object vs Obj)Map, WeakMap, Set, WeakSet, BigInt, Intl)open Js, you should feel at home)window, document and globalThis (they're basically typed as any)Nearly all data structures maintain compatible types with the default Js module.
Run the following in your console:
$ yarn add rescript-js
Then add rescript-js to your bsconfig.json's bs-dependencies:
{
"bs-dependencies": [
+ "rescript-js"
]
}
If you want to exclusively use rescript-js:
{
"bsc-flags": [
+ "-open ReScriptJs",
]
}
open ReScriptJs.Js
Console.log("Hello world!")
let timeout = setTimeout(() => {
Console.log("Hello!")
}, 100)
clearTimeout(timeout)
let array = [1, 2, 3]
let sum = array
->Array.map(x => x * 2)
->Array.reduce((acc, item) => acc + item, 0)
Available modules are listed in ReScriptJs.res
ReScript
100.0%
[!NOTE] This project is archived as it's now included as the standard library in ReScript 12 (https://rescript-lang.org/blog/release-12-0-0#improved-standard-library)
Bindings to the JS standard library
This is an alternative library to the default Js module.
Main differences:
Object vs Obj)Map, WeakMap, Set, WeakSet, BigInt, Intl)open Js, you should feel at home)window, document and globalThis (they're basically typed as any)Nearly all data structures maintain compatible types with the default Js module.
Run the following in your console:
$ yarn add rescript-js
Then add rescript-js to your bsconfig.json's bs-dependencies:
{
"bs-dependencies": [
+ "rescript-js"
]
}
If you want to exclusively use rescript-js:
{
"bsc-flags": [
+ "-open ReScriptJs",
]
}
open ReScriptJs.Js
Console.log("Hello world!")
let timeout = setTimeout(() => {
Console.log("Hello!")
}, 100)
clearTimeout(timeout)
let array = [1, 2, 3]
let sum = array
->Array.map(x => x * 2)
->Array.reduce((acc, item) => acc + item, 0)
Available modules are listed in ReScriptJs.res
ReScript
100.0%