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

[Feature]: Add compact representations for input/output. #56

Closed
wants to merge 9 commits into from

Conversation

LcyDev
Copy link
Collaborator

@LcyDev LcyDev commented Jul 21, 2023

  • [Feature Request]: Compact representations using metric prefixes #52

  • Implemented compact representations for input with validateAmount().

  • Implemented compact representations for output/display in liteEco.api.formatting()

  • Refactored repeated code for amount validation with validateAmount()

  • Implemented temporal translation for format_amount_error

  • Added config plugin.economy.compact_display to toggle compact representations for output.

* Optimized the call to compactNumber() for better efficiency.
* Simplified the moneyFormat() code to handle compaction logic more effectively.
* Added an isNumeric() extension check to handle NaN cases gracefully.
* Removed unnecessary code to enhance codebase maintainability.

Bugfixes:
* Now handling NaN values.
* Prevent null from compactChar in money suffix.
* Always add currencyName to suffix.
* Added extension String.isDecimal(), checking valid numeric Doubles

* Replaced isNumeric() call for isDecimal(), fixing issue where decimal points return null.

* Small refactor of compactNumber, replaced if-else with takeIf + let
@LcyDev LcyDev changed the title Abrv [Feature]: Add compact representations for input/output. Jul 21, 2023
@LcyDev LcyDev marked this pull request as draft July 21, 2023 18:53
* Replaced if-else with takeIf.
* Removed redundant "this" keywords.
* Added "Q" in compactNumber for Quadrillion display.

* Removed NOT operator in "isFinite()" check to correct bool value.
@LcyDev
Copy link
Collaborator Author

LcyDev commented Jul 21, 2023

Foolproofing:
imagen

Usage
imagen

There may be a problem when it rounds compact numbers for example "10.928M" to "10.93M"

However this only happens to the output, the real value is still correct.

@LcyDev
Copy link
Collaborator Author

LcyDev commented Jul 21, 2023

@EncryptSL What do you think of these changes?

Sorry i made excessive commits.
Maybe i'll redo this in a new branch and do a new pull request

@EncryptSL
Copy link
Owner

Changes looks good.

@LcyDev
Copy link
Collaborator Author

LcyDev commented Jul 25, 2023

Thanks, i'm working in other plugins but i'm still contributing to this plugin

I will upload the new pull request of this feature soon.

@EncryptSL
Copy link
Owner

Yep no problem

@LcyDev LcyDev closed this Jul 30, 2023
@LcyDev LcyDev deleted the abrv branch July 30, 2023 15:17
Repository owner locked and limited conversation to collaborators Aug 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants