Skip to content

Commit 564614d

Browse files
authored
Js.log -> Console.log (#768)
1 parent 47177b1 commit 564614d

25 files changed

+103
-103
lines changed

pages/docs/manual/latest/async-await.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let logUserDetails = async (userId: string) => {
3939
4040
await sendAnalytics(`User details have been logged for ${userId}`)
4141
42-
Js.log(`Email address for user ${userId}: ${email}`)
42+
Console.log(`Email address for user ${userId}: ${email}`)
4343
}
4444
```
4545

@@ -139,8 +139,8 @@ let checkAuth = async () => {
139139
} catch {
140140
| Js.Exn.Error(e) =>
141141
switch Js.Exn.message(e) {
142-
| Some(msg) => Js.log("JS error thrown: " ++ msg)
143-
| None => Js.log("Some other exception has been thrown")
142+
| Some(msg) => Console.log("JS error thrown: " ++ msg)
143+
| None => Console.log("Some other exception has been thrown")
144144
}
145145
}
146146
}
@@ -157,11 +157,11 @@ let authenticate = async () => {
157157
158158
let checkAuth = async () => {
159159
switch await authenticate() {
160-
| _ => Js.log("ok")
160+
| _ => Console.log("ok")
161161
| exception Js.Exn.Error(e) =>
162162
switch Js.Exn.message(e) {
163-
| Some(msg) => Js.log("JS error thrown: " ++ msg)
164-
| None => Js.log("Some other exception has been thrown")
163+
| Some(msg) => Console.log("JS error thrown: " ++ msg)
164+
| None => Console.log("Some other exception has been thrown")
165165
}
166166
}
167167
}
@@ -181,7 +181,7 @@ This can be done by wrapping your `await` calls in a new `{}` closure.
181181
182182
let fetchData = async () => {
183183
let mail = {await fetchUserMail("1234")}->Js.String2.toUpperCase
184-
Js.log(`All upper-cased mail: ${mail}`)
184+
Console.log(`All upper-cased mail: ${mail}`)
185185
}
186186
```
187187

@@ -208,11 +208,11 @@ Note how the original closure was removed in the final JS output. No extra alloc
208208
let fetchData = async () => {
209209
switch (await fetchUserMail("user1"), await fetchUserMail("user2")) {
210210
| (user1Mail, user2Mail) => {
211-
Js.log("user 1 mail: " ++ user1Mail)
212-
Js.log("user 2 mail: " ++ user2Mail)
211+
Console.log("user 1 mail: " ++ user1Mail)
212+
Console.log("user 2 mail: " ++ user2Mail)
213213
}
214214
215-
| exception JsError(err) => Js.log2("Some error occurred", err)
215+
| exception JsError(err) => Console.log2("Some error occurred", err)
216216
}
217217
}
218218
```
@@ -261,8 +261,8 @@ let logMultipleValues = async () => {
261261
let all = await Js.Promise2.all([promise1, promise2, promise3])
262262
263263
switch all {
264-
| [v1, v2, v3] => Js.log(`All values: ${v1}, ${v2}, ${v3}`)
265-
| _ => Js.log("this should never happen")
264+
| [v1, v2, v3] => Console.log(`All values: ${v1}, ${v2}, ${v3}`)
265+
| _ => Console.log("this should never happen")
266266
}
267267
}
268268
```

pages/docs/manual/latest/bind-to-global-js-values.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type timerId
4343
@val external setTimeout: (unit => unit, int) => timerId = "setTimeout"
4444
@val external clearTimeout: timerId => unit = "clearTimeout"
4545
46-
let id = setTimeout(() => Js.log("hello"), 100)
46+
let id = setTimeout(() => Console.log("hello"), 100)
4747
clearTimeout(id)
4848
```
4949
```js
@@ -102,8 +102,8 @@ For these troublesome global values, ReScript provides a special approach: `%ext
102102

103103
```res example
104104
switch %external(__DEV__) {
105-
| Some(_) => Js.log("dev mode")
106-
| None => Js.log("production mode")
105+
| Some(_) => Console.log("dev mode")
106+
| None => Console.log("production mode")
107107
}
108108
```
109109
```js
@@ -126,8 +126,8 @@ Another example:
126126

127127
```res example
128128
switch %external(__filename) {
129-
| Some(f) => Js.log(f)
130-
| None => Js.log("non-node environment")
129+
| Some(f) => Console.log(f)
130+
| None => Console.log("non-node environment")
131131
};
132132
```
133133
```js

pages/docs/manual/latest/bind-to-js-function.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ external on: (
283283
let register = rl =>
284284
rl
285285
->on(#close(event => ()))
286-
->on(#line(line => Js.log(line)));
286+
->on(#line(line => Console.log(line)));
287287
```
288288
```js
289289
function register(rl) {
@@ -313,7 +313,7 @@ external processOnExit: (
313313
) => unit = "process.on"
314314
315315
processOnExit(exitCode =>
316-
Js.log("error code: " ++ Js.Int.toString(exitCode))
316+
Console.log("error code: " ++ Js.Int.toString(exitCode))
317317
);
318318
```
319319
```js
@@ -365,7 +365,7 @@ type x
365365
@val external x: x = "x"
366366
@set external setOnload: (x, @this ((x, int) => unit)) => unit = "onload"
367367
@get external resp: x => int = "response"
368-
setOnload(x, @this (o, v) => Js.log(resp(o) + v))
368+
setOnload(x, @this (o, v) => Console.log(resp(o) + v))
369369
```
370370
```js
371371
x.onload = function (v) {

pages/docs/manual/latest/bind-to-js-object.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ type t
143143
144144
let i32arr = create(3)
145145
i32arr->set(0, 42)
146-
Js.log(i32arr->get(0))
146+
Console.log(i32arr->get(0))
147147
```
148148
```js
149149
var i32arr = new Int32Array(3);

pages/docs/manual/latest/build-external-stdlib.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Now the compiled JS code will import using the path defined by `external-stdlib`
4242
<CodeTab labels={["ReScript", "JS output"]}>
4343

4444
```res
45-
Array.forEach([1, 2, 3], num => Js.log(num))
45+
Array.forEach([1, 2, 3], num => Console.log(num))
4646
```
4747

4848
```js

pages/docs/manual/latest/control-flow.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ For loops iterate from a starting value up to (and including) the ending value.
9898

9999
```res
100100
for i in startValueInclusive to endValueInclusive {
101-
Js.log(i)
101+
Console.log(i)
102102
}
103103
```
104104
```js
@@ -114,7 +114,7 @@ for(var i = startValueInclusive; i <= endValueInclusive; ++i){
114114
```res example
115115
// prints: 1 2 3, one per line
116116
for x in 1 to 3 {
117-
Js.log(x)
117+
Console.log(x)
118118
}
119119
```
120120
```js
@@ -131,7 +131,7 @@ You can make the `for` loop count in the opposite direction by using `downto`.
131131

132132
```res
133133
for i in startValueInclusive downto endValueInclusive {
134-
Js.log(i)
134+
Console.log(i)
135135
}
136136
```
137137
```js
@@ -147,7 +147,7 @@ for(var i = startValueInclusive; i >= endValueInclusive; --i){
147147
```res example
148148
// prints: 3 2 1, one per line
149149
for x in 3 downto 1 {
150-
Js.log(x)
150+
Console.log(x)
151151
}
152152
```
153153
```js
@@ -190,7 +190,7 @@ while !break.contents {
190190
if Js.Math.random() > 0.3 {
191191
break := true
192192
} else {
193-
Js.log("Still running")
193+
Console.log("Still running")
194194
}
195195
}
196196
```

pages/docs/manual/latest/embed-raw-javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let add = %raw(`
4747
}
4848
`)
4949
50-
Js.log(add(1, 2))
50+
Console.log(add(1, 2))
5151
```
5252
```js
5353
var add = function(a, b) {

pages/docs/manual/latest/exception.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ You can directly match on exceptions _while_ getting another return value from a
6666

6767
```res prelude
6868
switch list{1, 2, 3}->List.getExn(4) {
69-
| item => Js.log(item)
70-
| exception Not_found => Js.log("No such item found!")
69+
| item => Console.log(item)
70+
| exception Not_found => Console.log("No such item found!")
7171
}
7272
```
7373
```js
@@ -160,7 +160,7 @@ try {
160160
} catch {
161161
| Js.Exn.Error(obj) =>
162162
switch Js.Exn.message(obj) {
163-
| Some(m) => Js.log("Caught a JS exception! Message: " ++ m)
163+
| Some(m) => Console.log("Caught a JS exception! Message: " ++ m)
164164
| None => ()
165165
}
166166
}

pages/docs/manual/latest/extensible-variant.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ Extensible variants are open-ended, so the compiler will not be able to exhausti
4848
```res
4949
let print = v =>
5050
switch v {
51-
| Point(x, y) => Js.log2("Point", (x, y))
52-
| Line(ax, ay, bx, by) => Js.log2("Line", (ax, ay, bx, by))
51+
| Point(x, y) => Console.log2("Point", (x, y))
52+
| Line(ax, ay, bx, by) => Console.log2("Line", (ax, ay, bx, by))
5353
| Other
54-
| _ => Js.log("Other")
54+
| _ => Console.log("Other")
5555
}
5656
```
5757
```js

pages/docs/manual/latest/external.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Once declared, you can use an `external` as a normal value, just like a let bind
5151
5252
// call a method
5353
document["addEventListener"](."mouseup", _event => {
54-
Js.log("clicked!")
54+
Console.log("clicked!")
5555
})
5656
5757
// get a property

pages/docs/manual/latest/generate-converters-accessors.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ let pets = [{name: "bob"}, {name: "bob2"}]
9191
pets
9292
->Array.map(name)
9393
->Array.joinWith("&")
94-
->Js.log
94+
->Console.log
9595
```
9696

9797
```js

pages/docs/manual/latest/import-from-export-to-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Use the value `"default"` on the right hand side:
8484

8585
```res example
8686
@module("./student") external studentName: string = "default"
87-
Js.log(studentName)
87+
Console.log(studentName)
8888
```
8989
```js
9090
import Student from "./student";

pages/docs/manual/latest/inlining-constants.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ So, in ReScript, producing that example `if (process.env.mode === 'development')
3434
let mode = "development"
3535
3636
if (process["env"]["mode"] === mode) {
37-
Js.log("Dev-only code here!")
37+
Console.log("Dev-only code here!")
3838
}
3939
```
4040
```js
@@ -58,7 +58,7 @@ The JS output shows `if (process.env.mode === mode)`, which isn't what we wanted
5858
let mode = "development"
5959
6060
if (process["env"]["mode"] === mode) {
61-
Js.log("Dev-only code here!")
61+
Console.log("Dev-only code here!")
6262
}
6363
```
6464
```js

pages/docs/manual/latest/interop-cheatsheet.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var result3 = Caml_option.nullable_to_opt(10);
159159
[1, 2, 3]
160160
->map(a => a + 1)
161161
->filter(a => mod(a, 2) == 0)
162-
->Js.log
162+
->Console.log
163163
```
164164
```js
165165
console.log(

pages/docs/manual/latest/json.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Use `Js.Json.stringify`:
3939
<CodeTab labels={["ReScript", "JS Output"]}>
4040

4141
```res example
42-
Js.log(Js.Json.stringifyAny(["Amy", "Joe"]))
42+
Console.log(Js.Json.stringifyAny(["Amy", "Joe"]))
4343
```
4444
```js
4545
console.log(JSON.stringify([

pages/docs/manual/latest/lazy-values.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ external readdirSync: string => array<string> = "readdirSync"
1616
1717
// Read the directory, only once
1818
let expensiveFilesRead = lazy({
19-
Js.log("Reading dir")
19+
Console.log("Reading dir")
2020
readdirSync("./pages")
2121
})
2222
```
@@ -46,10 +46,10 @@ To actually run the lazy value's computation, use `Lazy.force` from the globally
4646

4747
```res example
4848
// First call. The computation happens
49-
Js.log(Lazy.force(expensiveFilesRead)) // logs "Reading dir" and the directory content
49+
Console.log(Lazy.force(expensiveFilesRead)) // logs "Reading dir" and the directory content
5050
5151
// Second call. Will just return the already calculated result
52-
Js.log(Lazy.force(expensiveFilesRead)) // logs the directory content
52+
Console.log(Lazy.force(expensiveFilesRead)) // logs the directory content
5353
```
5454
```js
5555
console.log(CamlinternalLazy.force(expensiveFilesRead));
@@ -69,7 +69,7 @@ Instead of using `Lazy.force`, you can also use [pattern matching](pattern-match
6969

7070
```res example
7171
switch expensiveFilesRead {
72-
| lazy(result) => Js.log(result)
72+
| lazy(result) => Console.log(result)
7373
}
7474
```
7575
```js
@@ -84,7 +84,7 @@ Since pattern matching also works on a `let` binding, you can also do:
8484

8585
```res example
8686
let lazy(result) = expensiveFilesRead
87-
Js.log(result)
87+
Console.log(result)
8888
```
8989
```js
9090
var result = CamlinternalLazy.force(expensiveFilesRead);

pages/docs/manual/latest/let-binding.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ReScript's `if`, `while` and functions all use the same block scoping mechanism.
5454
```res
5555
if displayGreeting {
5656
let message = "Enjoying the docs so far?"
57-
Js.log(message)
57+
Console.log(message)
5858
}
5959
// `message` not accessible here!
6060
```

pages/docs/manual/latest/module.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ using the `.` notation. This demonstrates modules' utility for namespacing.
5555

5656
```res
5757
let anotherPerson: School.profession = School.Teacher
58-
Js.log(School.getProfession(anotherPerson)) /* "A teacher" */
58+
Console.log(School.getProfession(anotherPerson)) /* "A teacher" */
5959
```
6060
```js
6161
var anotherPerson = /* Teacher */0;

pages/docs/manual/latest/newcomer-examples.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ let possiblyNullValue1 = None
2121
let possiblyNullValue2 = Some("Hello")
2222
2323
switch possiblyNullValue2 {
24-
| None => Js.log("Nothing to see here.")
25-
| Some(message) => Js.log(message)
24+
| None => Console.log("Nothing to see here.")
25+
| Some(message) => Console.log(message)
2626
}
2727
```
2828
```js

pages/docs/manual/latest/null-undefined-option.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Later on, when another piece of code receives such value, it'd be forced to hand
6767
```res
6868
switch licenseNumber {
6969
| None =>
70-
Js.log("The person doesn't have a car")
70+
Console.log("The person doesn't have a car")
7171
| Some(number) =>
72-
Js.log("The person's license number is " ++ Js.Int.toString(number))
72+
Console.log("The person's license number is " ++ Js.Int.toString(number))
7373
}
7474
```
7575
```js

pages/docs/manual/latest/object.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Since objects don't require type declarations, and since ReScript infers all the
173173
174174
// call a method
175175
document["addEventListener"](. "mouseup", _event => {
176-
Js.log("clicked!")
176+
Console.log("clicked!")
177177
})
178178
179179
// get a property

0 commit comments

Comments
 (0)