You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For browsers, seems like the only way to do this is to add an own-property to the object (_repr_). In Node, you can use Symbol.for('nodejs.util.inspect.custom') (link).
@js-temporal/polyfill uses _repr_ for both browser/Node, and allows for conditional removal via injecting a __debug__ global.
I'm sensitive to people not wanting the upfront computation of _repr_ for all created Temporal objects, and I'd prefer not to force them to jump through hoops with their bundler to set __debug__ in order to strip it out.
I thought of a different solution: detect if the currently executing code is minified, and if it is, skip the _repr_ computation and assignment. You can detect like this:
For Node, we'd want to avoid all this and just use Symbol.for('nodejs.util.inspect.custom'). We might want to detect the environment using subpath imports.
If _repr_ needs to be computed up-front, we'd want to reuse the same value for future toString calls.
For example, when I'm using Google Chrome dev console, and I run this:
Here's what's shown for temporal-polyfill:
But @js-temporal/polyfill does it nicer:
TODO: figure out how to do something like this
The text was updated successfully, but these errors were encountered: