From 5143b9e7d3f72e6cc23f8381295df17ff1235f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 15 Jan 2024 01:26:57 +0100 Subject: feat(unstable): add Temporal API support (#21738) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: David Sherret Co-authored-by: Kenta Moriuchi --- ext/console/01_console.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'ext/console/01_console.js') 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; @@ -776,6 +777,55 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) { return ctx.stylize(base, "date"); } } + } 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) || -- cgit v1.2.3