Skip to content

Commit 0e605e0

Browse files
committed
Add optional ~options argument to Console.dir
1 parent 2193869 commit 0e605e0

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

runtime/Stdlib_Console.res

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
@val external debug6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.debug"
2020
@val @variadic external debugMany: array<_> => unit = "console.debug"
2121

22-
@val external dir: 'a => unit = "console.dir"
22+
type dirOptions = {
23+
colors?: bool,
24+
depth?: Stdlib_Nullable.t<int>,
25+
showHidden?: bool
26+
}
27+
@val external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"
2328
@val external dirxml: 'a => unit = "console.dirxml"
2429

2530
@val external error: 'a => unit = "console.error"

runtime/Stdlib_Console.resi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,13 @@ Console.debugMany([1, 2, 3])
244244
@variadic
245245
external debugMany: array<_> => unit = "console.debug"
246246

247+
type dirOptions = {
248+
colors?: bool,
249+
depth?: Stdlib_Nullable.t<int>,
250+
showHidden?: bool
251+
}
247252
/**
248-
`dir(object)` displays an interactive view of the object in the console.
253+
`dir(object, options)` displays an interactive view of the object in the console.
249254
250255
See [`console.dir`](https://developer.mozilla.org/en-US/docs/Web/API/console/dir)
251256
on MDN.
@@ -254,10 +259,11 @@ on MDN.
254259
255260
```rescript
256261
Console.dir({"language": "rescript", "version": "10.1.2"})
262+
Console.dir({"language": "rescript", "version": {"major": "10", "minor": "1", "patch": "2"}}, ~options={depth: null})
257263
```
258264
*/
259265
@val
260-
external dir: 'a => unit = "console.dir"
266+
external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"
261267

262268
/**
263269
`dirxml(object)` displays an interactive tree view of an XML/HTML element in the console.

0 commit comments

Comments
 (0)