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

[Suggestion]: Include a readonly preview value for easier debugging #721

Open
2 tasks done
GeoMarkou opened this issue Feb 16, 2023 · 0 comments
Open
2 tasks done
Assignees
Labels
bug Something isn't working v1 This concerns v1

Comments

@GeoMarkou
Copy link

GeoMarkou commented Feb 16, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When debugging, it's quite difficult to see what's actually going on with my numbers to make sure my math is correct, because there is no visual indication of the number that a Dinero object represents in the debugger. Everything is hidden behind a .toFormat() or .toUnit() function which you can't easily call in dev tools.

Expected behavior

I've already done this locally in my setup, but I thought it would be useful for other users too. I set a getter when creating the object which just shows a preview of the string value. You still need to click it in the dev console to see the amount which isn't ideal, but I wasn't sure if exposing the raw internal values was safe. It might be a good idea to include this in the Dinero source code behind a development environment flag or something.

export const dineroWithPreview = (options) => Object.defineProperty(dinero(options), '__preview__', { get() { return this.toFormat(); }})

Steps to reproduce

  1. Open the dev tools
  2. Debug a JavaScript file
  3. Have loads of Dinero objects you need to debug
  4. Get RSI rightclicking each Dinero object you need to check, while typing temp.toFormat() manually for each one

Version

1.9.1

Environment

Chrome

Code of Conduct

  • I agree to follow this project's Code of Conduct
@GeoMarkou GeoMarkou added the bug Something isn't working label Feb 16, 2023
@sarahdayan sarahdayan added the v1 This concerns v1 label Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v1 This concerns v1
Projects
None yet
Development

No branches or pull requests

2 participants