-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Unable to override custom symbols translations #176
Comments
Created a PR with proposed solution #175 |
Hi, I merged your PR assuming you ran the tests, but most tests failed, so it was force-pushed out. I'm adding husky to enforce pre-commit actions. > [email protected] mocha
> mocha test/*.js
Testing functionality
1) It should pass base2 tests
2) It should pass base2 JEDEC tests
3) It should pass base10 tests
4) It should pass base10 IEC tests
√ It should pass invalid input tests
5) It should pass symbols tests
6) It should pass partial() tests
7) It should pass bits tests
8) It should pass full forms tests
9) It should pass exponent tests
10) It should pass separator tests
11) It should pass locale tests
12) It should pass localeOptions tests
13) It should pass roundingMethod tests
14) It should pass precision tests
15) It should pass defaults tests
16) It should pass BigInt tests
1 passing (11ms)
16 failing
1) Testing functionality
It should pass base2 tests:
TypeError: Cannot read properties of undefined (reading 'bytes')
at filesize (file:///C:/Users/jason/Projects/filesize.js/dist/filesize.esm.js:158:31)
at Context.<anonymous> (file:///C:/Users/jason/Projects/filesize.js/test/filesize_test.js:21:16)
at process.processImmediate (node:internal/timers:478:21) |
This is actually a really old feature (3.0.0)*; I removed the block of samples from the README because it was an outdated gist. The tests are the easiest place to see how it's used:
|
I've returned the gist content to the README; that file & the dist outputs need to be updated. You only need to pass filesize(1, {symbols: {B: "Б"}}); // "1 Б"
filesize(12, {fullform: true, fullforms: ["байтов"]}); // "12 байтов" |
Closing this issue, with the intention to revisit the |
Hi @avoidwork Typescript code below |
Perhaps only the symbols option Type needs to be fixed and code would work as expected as per your example. |
Created another PR #177 with just type definition fix. |
@tschlechtweg, as the PR (#174) author who introduced the definition, is this looser version going to cause an issue? |
@avoidwork I would recommend if the object takes abritary strings as keys and values to atleast restrict it to |
@avoidwork It will not cause an issue with the return type infering, such that I do not have arguments against it. |
Thank you @avoidwork & @tschlechtweg |
Unable to override symbols using custom translation text. I couldn't find any examples to do so based on the new definition of symbols object. This is the best I could think of.
The text was updated successfully, but these errors were encountered: