diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-01-15 01:26:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-15 01:26:57 +0100 |
commit | 5143b9e7d3f72e6cc23f8381295df17ff1235f53 (patch) | |
tree | 6c8a59aa1fd0feb23601e009bde04c03c66e6593 /ext/console/01_console.js | |
parent | f46c03d6b4a59f5f1771cb3fbec15fe034b81dde (diff) |
feat(unstable): add Temporal API support (#21738)
This commit adds support for [Stage 3 Temporal API
proposal](https://tc39.es/proposal-temporal/docs/).
The API is available when `--unstable-temporal` flag is passed.
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
Co-authored-by: Kenta Moriuchi <moriken@kimamass.com>
Diffstat (limited to 'ext/console/01_console.js')
-rw-r--r-- | ext/console/01_console.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/console/01_console.js b/ext/console/01_console.js index ae629a432..101b7ed1c 100644 --- a/ext/console/01_console.js +++ b/ext/console/01_console.js @@ -188,6 +188,7 @@ const styles = { regexp: "red", module: "underline", internalError: "red", + temporal: "magenta", }; const defaultFG = 39; @@ -777,6 +778,55 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) { } } } else if ( + proxyDetails === null && + typeof globalThis.Temporal !== "undefined" && + ( + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.Instant.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.ZonedDateTime.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.PlainDate.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.PlainTime.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.PlainDateTime.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.PlainYearMonth.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.PlainMonthDay.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.Duration.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.TimeZone.prototype, + value, + ) || + ObjectPrototypeIsPrototypeOf( + globalThis.Temporal.Calendar.prototype, + value, + ) + ) + ) { + // Temporal is not available in primordials yet + // deno-lint-ignore prefer-primordials + return ctx.stylize(value.toString(), "temporal"); + } else if ( (proxyDetails === null && (isNativeError(value) || ObjectPrototypeIsPrototypeOf(ErrorPrototype, value))) || |