bitburner-official / bitburner-src

Bitburner source code.
Other
838 stars 273 forks source link

Deprecation of nFormat: no '0o' alternative for ex. 1st, 2nd, 3rd #1759

Closed mycroftjr closed 2 weeks ago

mycroftjr commented 2 weeks ago

It's a minor issue, but if nFormat is removed at the moment, then there will be no decent alternative to ns.nFormat(num, '0o') remaining (I believe the o stands for ordinal. It basically adds the suffixes for "1st", "2nd", "3rd", etc).

My scripts currently use this format string when talking about investment rounds for corporations - i.e.

throw `${ns.nFormat(offer.round, "0o")} investment offer asking for more than ${investInfo.sharePercent}% of shares???`;
catloversg commented 2 weeks ago

We don't have any plans to use or provide an alternative of Numeral.js (it's the library that we used for nFormat API). For the ordinal indicator, you can use Intl.PluralRules(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#using_options

mycroftjr commented 2 weeks ago

We don't have any plans to use or provide an alternative of Numeral.js (it's the library that we used for nFormat API). For the ordinal indicator, you can use Intl.PluralRules(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/PluralRules#using_options

Ah, could you perhaps mention that alongside the other ns.format methods as alternatives in the deprecation notice?