Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom inspect for node without depedency #1526

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

pedropedruzzi
Copy link
Contributor

@pedropedruzzi pedropedruzzi commented Oct 10, 2023

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

  • npm run build
  • npm run format-check
  • ./scripts/test
  • Manual
const { DateTime, Duration, Interval } = require('./build/cjs-browser/luxon')
Duration.fromObject({ seconds: 10 })
Interval.fromDateTimes(DateTime.now().minus({ days: 1 }), DateTime.now())
DateTime.now()

// 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
Copy link

linux-foundation-easycla bot commented Oct 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: pedropedruzzi / name: Pedro Pedruzzi (6fb10c2)

@icambron
Copy link
Member

This looks good, thanks

@icambron icambron merged commit eefe64e into moment:master Nov 12, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants