|
| 1 | +/*** |
| 2 | +Functions for interacting with JavaScript console. |
| 3 | +See: [`Console`](https://developer.mozilla.org/en-US/docs/Web/API/Console). |
| 4 | +*/ |
| 5 | + |
| 6 | +/** |
| 7 | +`log(value)` outputs a message to console. |
| 8 | +See [`Console.log`](https://developer.mozilla.org/en-US/docs/Web/API/console/log) |
| 9 | +on MDN. |
| 10 | +
|
| 11 | +## Examples |
| 12 | +
|
| 13 | +```rescript |
| 14 | +Console.log("Hello") |
| 15 | +let obj = {"name": "ReScript", "version": 10} |
| 16 | +Console.log(obj) |
| 17 | +``` |
| 18 | +*/ |
| 19 | +@val |
| 20 | +external log: 'a => unit = "console.log" |
| 21 | + |
| 22 | +/** |
| 23 | +`log2(v1, v2)`. Like `log`, but with two arguments. |
| 24 | +
|
| 25 | +## Examples |
| 26 | +
|
| 27 | +```rescript |
| 28 | +Console.log2("Hello", "World") |
| 29 | +Console.log2([1, 2, 3], [4]) |
| 30 | +``` |
| 31 | +*/ |
| 32 | +@val |
| 33 | +external log2: ('a, 'b) => unit = "console.log" |
| 34 | + |
| 35 | +/** |
| 36 | +`log3(v1, v2, v3)`. Like `log`, but with three arguments. |
| 37 | +
|
| 38 | +## Examples |
| 39 | +
|
| 40 | +```rescript |
| 41 | +Console.log3("Hello", "World", "ReScript") |
| 42 | +Console.log2([1, 2, 3], [4], [5]) |
| 43 | +``` |
| 44 | +*/ |
| 45 | +@val |
| 46 | +external log3: ('a, 'b, 'c) => unit = "console.log" |
| 47 | +/** |
| 48 | +`log4(v1, v2, v3, v4)`. Like `log`, but with four arguments. |
| 49 | +
|
| 50 | +## Examples |
| 51 | +
|
| 52 | +```rescript |
| 53 | +Console.log4("Hello", "World", "ReScript", "!!!") |
| 54 | +Console.log4([1, 2, 3], [4], [5]) |
| 55 | +``` |
| 56 | +*/ |
| 57 | +@val |
| 58 | +external log4: ('a, 'b, 'c, 'd) => unit = "console.log" |
| 59 | + |
| 60 | +/** |
| 61 | +`log5(v1, v2, v3, v4, v5)`. Like `log`, but with five arguments. |
| 62 | +
|
| 63 | +## Examples |
| 64 | +
|
| 65 | +```rescript |
| 66 | +Console.log5("Hello", "World", "from", "JS", "!!!") |
| 67 | +Console.log5(1, 2, 3, 4, 5) |
| 68 | +``` |
| 69 | +*/ |
| 70 | +@val |
| 71 | +external log5: ('a, 'b, 'c, 'd, 'e) => unit = "console.log" |
| 72 | +/** |
| 73 | +`info(value)` outputs an informational message to console. |
| 74 | +See [`Console.info`](https://developer.mozilla.org/en-US/docs/Web/API/console/info) |
| 75 | +on MDN. |
| 76 | +
|
| 77 | +## Examples |
| 78 | +
|
| 79 | +```rescript |
| 80 | +Console.info("Hello") |
| 81 | +Console.info([1, 2, 3]) |
| 82 | +Console.info(("Hello", "ReScript")) |
| 83 | +``` |
| 84 | +*/ |
| 85 | +@val |
| 86 | +external info: 'a => unit = "console.info" |
| 87 | + |
| 88 | +/** |
| 89 | +`info2(v1, v2)`. Like `info`, but two arguments. |
| 90 | +
|
| 91 | +## Examples |
| 92 | +
|
| 93 | +```rescript |
| 94 | +Console.info2("Failed to", "download") |
| 95 | +Console.info2([""]) |
| 96 | +``` |
| 97 | +*/ |
| 98 | +@val |
| 99 | +external info2: ('a, 'b) => unit = "console.info" |
| 100 | + |
| 101 | +/** |
| 102 | +`info3(v1, v2, v3)`. Like `info`, but three arguments. |
| 103 | +
|
| 104 | +## Examples |
| 105 | +
|
| 106 | +```rescript |
| 107 | +Console.info3("Hello", "World", "ReScript") |
| 108 | +Console.info3([1, 2, 3], [4], [5]) |
| 109 | +``` |
| 110 | +*/ |
| 111 | +@val |
| 112 | +external info3: ('a, 'b, 'c) => unit = "console.info" |
| 113 | + |
| 114 | +/** |
| 115 | +`info4(v1, v2, v3, v4)`. Like `info`, but with four arguments. |
| 116 | +
|
| 117 | +## Examples |
| 118 | +
|
| 119 | +```rescript |
| 120 | +Console.info4("Hello", "World", "ReScript", "!!!") |
| 121 | +Console.info4([1, 2, 3], [4], [5]) |
| 122 | +``` |
| 123 | +*/ |
| 124 | +@val |
| 125 | +external info4: ('a, 'b, 'c, 'd) => unit = "console.info" |
| 126 | + |
| 127 | +/** |
| 128 | +`info5(v1, v2, v3, v4, v5)`. Like `info`, but with five arguments. |
| 129 | +
|
| 130 | +## Examples |
| 131 | +
|
| 132 | +```rescript |
| 133 | +Console.info5("Hello", "World", "from", "JS", "!!!") |
| 134 | +Console.info5(1, 2, 3, 4, 5) |
| 135 | +``` |
| 136 | +*/ |
| 137 | +@val |
| 138 | +external info5: ('a, 'b, 'c, 'd, 'e) => unit = "console.info" |
| 139 | + |
| 140 | +/** |
| 141 | +`warn(value)` outputs a warning message to console. |
| 142 | +See [`Console.warn`](https://developer.mozilla.org/en-US/docs/Web/API/console/warn) |
| 143 | +on MDN. |
| 144 | +
|
| 145 | +## Examples |
| 146 | +
|
| 147 | +```rescript |
| 148 | +Console.warn("Hello") |
| 149 | +Console.warn([1, 2, 3]) |
| 150 | +Console.warn(("Hello", "ReScript")) |
| 151 | +``` |
| 152 | +*/ |
| 153 | +@val |
| 154 | +external warn: 'a => unit = "console.warn" |
| 155 | + |
| 156 | +/** |
| 157 | +`warn2(v1, v2)`. Like `warn`, but two arguments. |
| 158 | +
|
| 159 | +## Examples |
| 160 | +
|
| 161 | +```rescript |
| 162 | +Console.warn2("Hello", "World") |
| 163 | +Console.warn2([1, 2, 3], [4]) |
| 164 | +``` |
| 165 | +*/ |
| 166 | +@val |
| 167 | +external warn2: ('a, 'b) => unit = "console.warn" |
| 168 | + |
| 169 | +/** |
| 170 | +`warn3(v1, v2, v3)`. Like `warn`, but three arguments. |
| 171 | +
|
| 172 | +## Examples |
| 173 | +
|
| 174 | +```rescript |
| 175 | +Console.warn3("Hello", "World", "ReScript") |
| 176 | +Console.warn3([1, 2, 3], [4], [5]) |
| 177 | +``` |
| 178 | +*/ |
| 179 | +@val |
| 180 | +external warn3: ('a, 'b, 'c) => unit = "console.warn" |
| 181 | + |
| 182 | +/** |
| 183 | +`warn4(v1, v2, v3, v4)`. Like `warn`, but with four arguments. |
| 184 | +
|
| 185 | +## Examples |
| 186 | +
|
| 187 | +```rescript |
| 188 | +Console.warn4("Hello", "World", "ReScript", "!!!") |
| 189 | +Console.warn4([1, 2, 3], [4], [5]) |
| 190 | +``` |
| 191 | +*/ |
| 192 | +@val |
| 193 | +external warn4: ('a, 'b, 'c, 'd) => unit = "console.warn" |
| 194 | + |
| 195 | +/** |
| 196 | +`warn5(v1, v2, v3, v4, v5)`. Like `warn`, but with five arguments. |
| 197 | +
|
| 198 | +## Examples |
| 199 | +
|
| 200 | +```rescript |
| 201 | +Console.warn5("Hello", "World", "from", "JS", "!!!") |
| 202 | +Console.warn5(1, 2, 3, 4, 5) |
| 203 | +``` |
| 204 | +*/ |
| 205 | +@val |
| 206 | +external warn5: ('a, 'b, 'c, 'd, 'e) => unit = "console.warn" |
| 207 | + |
| 208 | +/** |
| 209 | +`error(value)` outputs an error message to console. |
| 210 | +See [`Console.error`](https://developer.mozilla.org/en-US/docs/Web/API/console/error) |
| 211 | +on MDN. |
| 212 | +
|
| 213 | +## Examples |
| 214 | +
|
| 215 | +```rescript |
| 216 | +Console.error("Hello") |
| 217 | +Console.error([1, 2, 3]) |
| 218 | +Console.error(("Hello", "ReScript")) |
| 219 | +``` |
| 220 | +*/ |
| 221 | +@val |
| 222 | +external error: 'a => unit = "console.error" |
| 223 | + |
| 224 | +/** |
| 225 | +`error(v1, v2)`. Like `error`, but two arguments. |
| 226 | +
|
| 227 | +## Examples |
| 228 | +
|
| 229 | +```rescript |
| 230 | +Console.error("Hello", "World") |
| 231 | +Console.error([1, 2, 3], [4]) |
| 232 | +``` |
| 233 | +*/ |
| 234 | +@val |
| 235 | +external error2: ('a, 'b) => unit = "console.error" |
| 236 | + |
| 237 | +/** |
| 238 | +`error3(v1, v2, v3)`. Like `error`, but three arguments. |
| 239 | +
|
| 240 | +## Examples |
| 241 | +
|
| 242 | +```rescript |
| 243 | +Console.error3("Hello", "World", "ReScript") |
| 244 | +Console.error3([1, 2, 3], [4], [5]) |
| 245 | +``` |
| 246 | +*/ |
| 247 | +@val |
| 248 | +external error3: ('a, 'b, 'c) => unit = "console.error" |
| 249 | + |
| 250 | +/** |
| 251 | +`error4(v1, v2, v3, v4)`. Like `error`, but with four arguments. |
| 252 | +
|
| 253 | +## Examples |
| 254 | +
|
| 255 | +```rescript |
| 256 | +Console.error("Hello", "World", "ReScript", "!!!") |
| 257 | +Console.error([1, 2, 3], [4], [5]) |
| 258 | +``` |
| 259 | +*/ |
| 260 | +@val |
| 261 | +external error4: ('a, 'b, 'c, 'd) => unit = "console.error" |
| 262 | + |
| 263 | +/** |
| 264 | +`error5(v1, v2, v3, v4, v5)`. Like `error`, but with five arguments. |
| 265 | +
|
| 266 | +## Examples |
| 267 | +
|
| 268 | +```rescript |
| 269 | +Console.error5("Hello", "World", "from", "JS", "!!!") |
| 270 | +Console.error5(1, 2, 3, 4, 5) |
| 271 | +``` |
| 272 | +*/ |
| 273 | +@val |
| 274 | +external error5: ('a, 'b, 'c, 'd, 'e) => unit = "console.error" |
| 275 | + |
| 276 | +/** |
| 277 | +`trace()` outputs a stack trace to console. |
| 278 | +See [`Console.trace`](https://developer.mozilla.org/en-US/docs/Web/API/console/trace) |
| 279 | +on MDN. |
| 280 | +
|
| 281 | +## Examples |
| 282 | +
|
| 283 | +```rescript |
| 284 | +let main = () => { |
| 285 | + Console.trace() |
| 286 | +} |
| 287 | +main() |
| 288 | +// In the console, the following trace will be displayed: |
| 289 | +// main |
| 290 | +// <anonymous> |
| 291 | +``` |
| 292 | +*/ |
| 293 | +@val |
| 294 | +external trace: unit => unit = "console.trace" |
| 295 | + |
| 296 | +/** |
| 297 | +`time(label)` starts a timer you can use to track how long an operation takes. |
| 298 | +You give each timer a unique name `label`, and may have up to 10,000 timers |
| 299 | +running on a given page. Call `Console.timeEnd` with the same `label` to browser |
| 300 | +output time, in milliseconds. |
| 301 | +See [`Console.time`](https://developer.mozilla.org/en-US/docs/Web/API/console/time) |
| 302 | +on MDN. |
| 303 | +
|
| 304 | +## Examples |
| 305 | +
|
| 306 | +```rescript |
| 307 | +Console.time("for_time") |
| 308 | +for x in 3 downto 1 { |
| 309 | + Console.log(x) |
| 310 | +} |
| 311 | +Console.timeEnd("for_time") |
| 312 | +``` |
| 313 | +*/ |
| 314 | +@val |
| 315 | +external time: string => unit = "console.time" |
| 316 | + |
| 317 | +/** |
| 318 | +`timeEnd(label)` stops a timer that was previously started by calling |
| 319 | +`Console.time(label)`. See [`Console.timeEnd`](https://developer.mozilla.org/en-US/docs/Web/API/console/timeEnd) |
| 320 | +on MDN. |
| 321 | +
|
| 322 | +## Examples |
| 323 | +
|
| 324 | +```rescript |
| 325 | +Console.time("for_time") |
| 326 | +for x in 3 downto 1 { |
| 327 | + Console.log(x) |
| 328 | +} |
| 329 | +Console.timeEnd("for_time") |
| 330 | +``` |
| 331 | +*/ |
| 332 | +@val |
| 333 | +external timeEnd: string => unit = "console.timeEnd" |
0 commit comments