UNPKG

numbr

Version:

A fast number formatting library, based on Numeral.js

945 lines (285 loc) 11.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Numbr</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Numbr</h1> <section> <header> <h2> <span class="ancestors"><a href="numbr.html">numbr</a>.</span> Numbr </h2> </header> <article> <div class="container-overview"> <dt> <h4 class="name" id="Numbr"><span class="type-signature"></span>new Numbr<span class="signature">(value, lang<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> A wrapper for numeral-like formatting </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>value</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>lang</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line27">line 27</a> </li></ul></dd> </dl> </dd> </div> <h3 class="subsection-title">Methods</h3> <dl> <dt> <h4 class="name" id="clone"><span class="type-signature"></span>clone<span class="signature">()</span><span class="type-signature"> &rarr; {Numbr}</span></h4> </dt> <dd> <div class="description"> Returns a new Numbr object with the same value and language as this Numbr. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line81">line 81</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Numbr</span> </dd> </dl> </dd> <dt> <h4 class="name" id="format"><span class="type-signature"></span>format<span class="signature">(fmt<span class="signature-attributes">opt</span>, roundFn<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {string}</span></h4> </dt> <dd> <div class="description"> Formats the wrapped value according to fmt. By default, the format is compiled into a series of transformations and then cached globally, if you'd like to disable the caching feature, use <a href="numbr.html#cacheEnabled">numbr.cacheEnabled</a>. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>fmt</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>roundFn</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> Math.round </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line40">line 40</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The formatted number </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> </dd> <dt> <h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(num)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Sets the wrapped value </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>num</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line73">line 73</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="setLang"><span class="type-signature"></span>setLang<span class="signature">(lang)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Sets the language for this Numbr. The provided language must be already loaded via numbr.loadLang. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>lang</code></td> <td class="type"> </td> <td class="description last">The language code</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line49">line 49</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="value"><span class="type-signature"></span>value<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4> </dt> <dd> <div class="description"> Access to the wrapped value </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line65">line 65</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> </dd> <dt> <h4 class="name" id="valueOf"><span class="type-signature"></span>valueOf<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4> </dt> <dd> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="numbr.js.html">numbr.js</a>, <a href="numbr.js.html#line57">line 57</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="numbr.CompiledFormat.html">CompiledFormat</a></li><li><a href="numbr.Consumer.html">Consumer</a></li><li><a href="numbr.Numbr.html">Numbr</a></li><li><a href="numbr.Step.html">Step</a></li></ul><h3>Namespaces</h3><ul><li><a href="numbr.html">numbr</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Sep 30 2014 02:08:18 GMT-0500 (Central Daylight Time (Mexico)) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>