moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.12k stars 728 forks source link

Add custom inspect for node without depedency #1526

Closed pedropedruzzi closed 8 months ago

pedropedruzzi commented 9 months ago

Adds back the custom inspection functions for node.js, first added by #281 then removed by #318 and [55ac17e]. This change avoids the default node's object inspection listing all fields recursively. This time there are no node imports or any run-time dependency. We simply expose the inspect functions as symbol-named attribute Symbol.for('nodejs.util.inspect.custom') as described in the docs.

Note: I've simplified the formats from the original addition to make it single line and simpler.

Testing done

// output: Duration { values: {"seconds":10} } Interval { start: 2023-10-09T16:20:51.017-03:00, end: 2023-10-10T16:20:51.019-03:00 } DateTime { ts: 2023-10-10T16:20:59.623-03:00, zone: America/Sao_Paulo, locale: en-US }

linux-foundation-easycla[bot] commented 9 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

icambron commented 8 months ago

This looks good, thanks