Various QOL improvements and bug fixes

This commit is contained in:
danielyxie
2019-02-08 18:46:30 -08:00
parent 8c8e3f2476
commit 840df3087f
14 changed files with 221 additions and 68 deletions

View File

@@ -1211,6 +1211,26 @@ vsprintf
See `this link <https://github.com/alexei/sprintf.js>`_ for details.
nFormat
^^^^^^^
.. js:function:: nFormat(n, format)
:param number n: Number to format
:param string format: Formatter
Converts a number into a string with the specified formatter. This uses the
`numeraljs <http://numeraljs.com/>`_ library, so the formatters must be compatible
with that.
This is the same function that the game itself uses to display numbers.
Examples::
nFormat(1.23e9, "$0.000a"); // Returns "$1.230b"
nFormat(12345.678, "0,0"); // Returns "12,346"
nFormat(0.84, "0.0%"); // Returns "84.0%
prompt
^^^^^^