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

0 commit comments

Comments
 (0)