UNPKG

flavor-js

Version:

FlavorJS the definitive JS natives chainable extensions methods (based on lodash & ES6)

2,989 lines (872 loc) 73.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>number - Documentation</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.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="FlavorJS.html">FlavorJS</a><ul class='methods'><li data-type='method'><a href="FlavorJS.html#delay">delay</a></li><li data-type='method'><a href="FlavorJS.html#extendArray">extendArray</a></li><li data-type='method'><a href="FlavorJS.html#extendBoolean">extendBoolean</a></li><li data-type='method'><a href="FlavorJS.html#extendDate">extendDate</a></li><li data-type='method'><a href="FlavorJS.html#extendFunction">extendFunction</a></li><li data-type='method'><a href="FlavorJS.html#extendLodash">extendLodash</a></li><li data-type='method'><a href="FlavorJS.html#extendNumber">extendNumber</a></li><li data-type='method'><a href="FlavorJS.html#extendObject">extendObject</a></li><li data-type='method'><a href="FlavorJS.html#extendPrototype">extendPrototype</a></li><li data-type='method'><a href="FlavorJS.html#extendPrototypeProperty">extendPrototypeProperty</a></li><li data-type='method'><a href="FlavorJS.html#extendString">extendString</a></li><li data-type='method'><a href="FlavorJS.html#init">init</a></li></ul></li></ul><h3>Namespaces</h3><ul><li><a href="array.html">array</a><ul class='methods'><li data-type='method'><a href="array.html#clone">clone</a></li><li data-type='method'><a href="array.html#concat">concat</a></li><li data-type='method'><a href="array.html#contains">contains</a></li><li data-type='method'><a href="array.html#containsBy">containsBy</a></li><li data-type='method'><a href="array.html#countBy">countBy</a></li><li data-type='method'><a href="array.html#cut">cut</a></li><li data-type='method'><a href="array.html#deepFindBy">deepFindBy</a></li><li data-type='method'><a href="array.html#deepMap">deepMap</a></li><li data-type='method'><a href="array.html#deepSortBy">deepSortBy</a></li><li data-type='method'><a href="array.html#diff">diff</a></li><li data-type='method'><a href="array.html#diffBy">diffBy</a></li><li data-type='method'><a href="array.html#distinct">distinct</a></li><li data-type='method'><a href="array.html#each">each</a></li><li data-type='method'><a href="array.html#filterBy">filterBy</a></li><li data-type='method'><a href="array.html#findBy">findBy</a></li><li data-type='method'><a href="array.html#first">first</a></li><li data-type='method'><a href="array.html#flatten">flatten</a></li><li data-type='method'><a href="array.html#indexBy">indexBy</a></li><li data-type='method'><a href="array.html#intersection">intersection</a></li><li data-type='method'><a href="array.html#isArray">isArray</a></li><li data-type='method'><a href="array.html#last">last</a></li><li data-type='method'><a href="array.html#lorem">lorem</a></li><li data-type='method'><a href="array.html#maxBy">maxBy</a></li><li data-type='method'><a href="array.html#pull">pull</a></li><li data-type='method'><a href="array.html#pullBy">pullBy</a></li><li data-type='method'><a href="array.html#random">random</a></li><li data-type='method'><a href="array.html#removeBy">removeBy</a></li><li data-type='method'><a href="array.html#shuffle">shuffle</a></li><li data-type='method'><a href="array.html#sortBy">sortBy</a></li><li data-type='method'><a href="array.html#split">split</a></li><li data-type='method'><a href="array.html#sum">sum</a></li><li data-type='method'><a href="array.html#tail">tail</a></li><li data-type='method'><a href="array.html#tail">tail</a></li><li data-type='method'><a href="array.html#union">union</a></li></ul></li><li><a href="boolean.html">boolean</a><ul class='methods'><li data-type='method'><a href="boolean.html#isBoolean">isBoolean</a></li><li data-type='method'><a href="boolean.html#random">random</a></li></ul></li><li><a href="date.html">date</a><ul class='methods'><li data-type='method'><a href="date.html#isDate">isDate</a></li><li data-type='method'><a href="date.html#random">random</a></li><li data-type='method'><a href="date.html#toTimestamp">toTimestamp</a></li></ul></li><li><a href="function.html">function</a><ul class='methods'><li data-type='method'><a href="function.html#isFunction">isFunction</a></li><li data-type='method'><a href="function.html#proxy">proxy</a></li></ul></li><li><a href="lodash.html">lodash</a><ul class='methods'><li data-type='method'><a href="lodash.html#deepFindBy">deepFindBy</a></li><li data-type='method'><a href="lodash.html#deepMap">deepMap</a></li><li data-type='method'><a href="lodash.html#deepOrderBy">deepOrderBy</a></li><li data-type='method'><a href="lodash.html#filterByValues">filterByValues</a></li><li data-type='method'><a href="lodash.html#isPercentage">isPercentage</a></li><li data-type='method'><a href="lodash.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="lodash.html#pullAllByComparator">pullAllByComparator</a></li><li data-type='method'><a href="lodash.html#timesRange">timesRange</a></li><li data-type='method'><a href="lodash.html#timesReverse">timesReverse</a></li></ul></li><li><a href="number.html">number</a><ul class='methods'><li data-type='method'><a href="number.html#between">between</a></li><li data-type='method'><a href="number.html#degreeDiff">degreeDiff</a></li><li data-type='method'><a href="number.html#degreeDir">degreeDir</a></li><li data-type='method'><a href="number.html#degreeWrap">degreeWrap</a></li><li data-type='method'><a href="number.html#floor">floor</a></li><li data-type='method'><a href="number.html#fromRoman">fromRoman</a></li><li data-type='method'><a href="number.html#isNumber">isNumber</a></li><li data-type='method'><a href="number.html#parse">parse</a></li><li data-type='method'><a href="number.html#random">random</a></li><li data-type='method'><a href="number.html#range">range</a></li><li data-type='method'><a href="number.html#round">round</a></li><li data-type='method'><a href="number.html#round">round</a></li><li data-type='method'><a href="number.html#times">times</a></li><li data-type='method'><a href="number.html#toAbsolute">toAbsolute</a></li><li data-type='method'><a href="number.html#toCurrency">toCurrency</a></li><li data-type='method'><a href="number.html#toFileSize">toFileSize</a></li><li data-type='method'><a href="number.html#toRoman">toRoman</a></li><li data-type='method'><a href="number.html#toSymbolString">toSymbolString</a></li></ul></li><li><a href="object.html">object</a><ul class='methods'><li data-type='method'><a href="object.html#clone">clone</a></li><li data-type='method'><a href="object.html#each">each</a></li><li data-type='method'><a href="object.html#inherit">inherit</a></li><li data-type='method'><a href="object.html#isObject">isObject</a></li><li data-type='method'><a href="object.html#omit">omit</a></li><li data-type='method'><a href="object.html#path">path</a></li><li data-type='method'><a href="object.html#pick">pick</a></li></ul></li><li><a href="string.html">string</a><ul class='methods'><li data-type='method'><a href="string.html#camelCase">camelCase</a></li><li data-type='method'><a href="string.html#capitalize">capitalize</a></li><li data-type='method'><a href="string.html#contains">contains</a></li><li data-type='method'><a href="string.html#decodeURI">decodeURI</a></li><li data-type='method'><a href="string.html#encodeURI">encodeURI</a></li><li data-type='method'><a href="string.html#endsWith">endsWith</a></li><li data-type='method'><a href="string.html#escapeHTML">escapeHTML</a></li><li data-type='method'><a href="string.html#escapeHTML">escapeHTML</a></li><li data-type='method'><a href="string.html#extractDomain">extractDomain</a></li><li data-type='method'><a href="string.html#extractFileExtension">extractFileExtension</a></li><li data-type='method'><a href="string.html#extractQueryString">extractQueryString</a></li><li data-type='method'><a href="string.html#guid">guid</a></li><li data-type='method'><a href="string.html#isRoman">isRoman</a></li><li data-type='method'><a href="string.html#isString">isString</a></li><li data-type='method'><a href="string.html#isUrl">isUrl</a></li><li data-type='method'><a href="string.html#pad">pad</a></li><li data-type='method'><a href="string.html#padLeft">padLeft</a></li><li data-type='method'><a href="string.html#padRight">padRight</a></li><li data-type='method'><a href="string.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="string.html#parsePercentage">parsePercentage</a></li><li data-type='method'><a href="string.html#replaceAll">replaceAll</a></li><li data-type='method'><a href="string.html#slugify">slugify</a></li><li data-type='method'><a href="string.html#startsWith">startsWith</a></li><li data-type='method'><a href="string.html#stripTags">stripTags</a></li><li data-type='method'><a href="string.html#toArray">toArray</a></li><li data-type='method'><a href="string.html#toInt">toInt</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3> </nav> <div id="main"> <h1 class="page-title">number</h1> <section> <header> <h2> number </h2> </header> <article> <div class="container-overview"> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line3">line 3</a> </li></ul></dd> </dl> <div class="description">the JS native Number class</div> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="between"><span class="type-signature"></span>between<span class="signature">(n, from<span class="signature-attributes">opt</span>, to<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*|<a href="boolean.html">boolean</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line30">line 30</a> </li></ul></dd> </dl> <div class="description"> checks if a number is between a range </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log((5).between(1, 10)); // true console.log((5).between(1, 4)); // false</code></pre> <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>n</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the number</td> </tr> <tr> <td class="name"><code>from</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>Number.MIN_VALUE</code> </td> <td class="description last">the from number</td> </tr> <tr> <td class="name"><code>to</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>Number.MAX_VALUE</code> </td> <td class="description last">the to number</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type"><a href="boolean.html">boolean</a></span> </dd> </dl> <h4 class="name" id="degreeDiff"><span class="type-signature"></span>degreeDiff<span class="signature">(a1, a2)</span><span class="type-signature"> &rarr; {Number}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line469">line 469</a> </li></ul></dd> </dl> <div class="description"> Returns the minimum distance from angle `a1` to `a2` (both in degrees). The result is kept between 0 and 359. </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>a1</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The initial angle in degrees.</td> </tr> <tr> <td class="name"><code>a2</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The final angle in degrees.</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> The angle distance value. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="degreeDir"><span class="type-signature"></span>degreeDir<span class="signature">(a1, a2)</span><span class="type-signature"> &rarr; {Integer}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line488">line 488</a> </li></ul></dd> </dl> <div class="description"> Returns the direction that represents the minimum distance from angle `a1` to `a2` (in degrees). The result is `-1`, `1`, or `0` if equal. </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>a1</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The initial angle in degrees.</td> </tr> <tr> <td class="name"><code>a2</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The final angle in degrees.</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> A direction -1, 1 or 0. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">Integer</span> </dd> </dl> <h4 class="name" id="degreeWrap"><span class="type-signature"></span>degreeWrap<span class="signature">(angle)</span><span class="type-signature"> &rarr; {Number}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line452">line 452</a> </li></ul></dd> </dl> <div class="description"> wraps an angle value (in degrees) between 0 and 359. </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>angle</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last">The angle in degrees.</td> </tr> </tbody> </table> <h5>Returns:</h5> <div class="param-desc"> The wrapped value. </div> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type">Number</span> </dd> </dl> <h4 class="name" id="floor"><span class="type-signature"></span>floor<span class="signature">(n, precision<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line305">line 305</a> </li></ul></dd> </dl> <div class="description"> floors a value </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log((5.076).floor()); // 4 console.log((5.076).floor(2)); // 5.07 console.log((5070).floor(-2)); // 5000</code></pre> <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>n</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the number</td> </tr> <tr> <td class="name"><code>precision</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>0</code> </td> <td class="description last">the precision number</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> </dd> </dl> <h4 class="name" id="fromRoman"><span class="type-signature"></span>fromRoman<span class="signature">(s)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line125">line 125</a> </li></ul></dd> </dl> <div class="description"> converts a Romans Number String in a Decimal Number </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log(Number.fromRoman('MCMLXXX')); // 1980</code></pre> <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>s</code></td> <td class="type"> <span class="param-type"><a href="string.html">string</a></span> </td> <td class="description last">the roman number string</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> </dd> </dl> <h4 class="name" id="isNumber"><span class="type-signature"></span>isNumber<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="boolean.html">boolean</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line9">line 9</a> </li></ul></dd> </dl> <div class="description"> check if something is a number </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>var n = 1; console.log(Number.isNumber(n)); // true console.log(Number.isNumber(2)); // true console.log(Number.isNumber('')); // false console.log(Number.isNumber(null)); // false</code></pre> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="boolean.html">boolean</a></span> </dd> </dl> <h4 class="name" id="parse"><span class="type-signature"></span>parse<span class="signature">(n)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>|null}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line52">line 52</a> </li></ul></dd> </dl> <div class="description"> parse a number value, returns null if parsing failes </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log(Number.parse("1")); // 1 console.log(Number.parse("1,25")); // 1.25 console.log(Number.parse({})); // null</code></pre> <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>n</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">the value to be parsed</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> | <span class="param-type">null</span> </dd> </dl> <h4 class="name" id="random"><span class="type-signature"></span>random<span class="signature">(lower<span class="signature-attributes">opt</span>, upper<span class="signature-attributes">opt</span>, floating<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line105">line 105</a> </li></ul></dd> </dl> <div class="description"> randomizes a number </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log(Number.random(1, 5)); // a number between 1 and 5 console.log(Number.random(1, 5, true)); // a number between 1.0 and 5.0 console.log(Number.random()); // a number between Number.MIN_VALUE and Number.MAX_VALUE</code></pre> <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>lower</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>Number.MIN_VALUE</code> </td> <td class="description last">the lower number</td> </tr> <tr> <td class="name"><code>upper</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>Number.MAX_VALUE</code> </td> <td class="description last">the upper number</td> </tr> <tr> <td class="name"><code>floating</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last">ask to return a floating number value</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> </dd> </dl> <h4 class="name" id="range"><span class="type-signature"></span>range<span class="signature">(start<span class="signature-attributes">opt</span>, end, reverse, step<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="array.html">array</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line391">line 391</a> </li></ul></dd> </dl> <div class="description"> Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. A step of -1 is used if a negative start is specified without an end or step. If end is not specified, it's set to start with start then set to 0. </div> <h5>Examples</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log(Array.range(4)); // [0, 1, 2, 3] console.log(Array.range(-4)); // [0, -1, -2, -3] console.log(Array.range(1, 5)); // [1, 2, 3, 4] console.log(Array.range(0, 20, 5)); // [0, 5, 10, 15] console.log(Array.range(0, -4, -1)); // [0, -1, -2, -3] console.log(Array.range(1, 4, 0)); // [1, 1, 1] console.log(Array.range(0); // []</code></pre> <p class="code-caption">eg. usage (reverse)</p> <pre class="prettyprint"><code>console.log(Array.rangeRight(4)); // [3, 2, 1, 0] console.log(Array.rangeRight(-4)); // [-3, -2, -1, 0] console.log(Array.rangeRight(1, 5)); // [4, 3, 2, 1] console.log(Array.rangeRight(0, 20, 5)); // [15, 10, 5, 0] console.log(Array.rangeRight(0, -4, -1)); // [-3, -2, -1, 0] console.log(Array.rangeRight(1, 4, 0)); // [1, 1, 1] console.log(Array.rangeRight(0)); // []</code></pre> <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>start</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>0</code> </td> <td class="description last">the start of the range</td> </tr> <tr> <td class="name"><code>end</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the end of the range</td> </tr> <tr> <td class="name"><code>reverse</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">true, if ou want a reverse range</td> </tr> <tr> <td class="name"><code>step</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>1</code> </td> <td class="description last">the value to increment or decrement by</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="array.html">array</a></span> </dd> </dl> <h4 class="name" id="round"><span class="type-signature"></span>round<span class="signature">(n, precision<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line356">line 356</a> </li></ul></dd> </dl> <div class="description"> crops a value between specified bounds </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log(Number.crop(5, 1, 10)); // 5 console.log(Number.crop(5, 2, 4)); // 4 console.log(Number.crop(5, 2)); // 5 console.log(Number.crop(5, 6)); // 6 console.log(Number.crop('5')); // '5' console.log((5).crop(1, 10)); // 5 console.log((5).crop(2, 4)); // 4 console.log((5).crop(2)); // 5 console.log((5).crop(6)); // 6</code></pre> <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>n</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the number</td> </tr> <tr> <td class="name"><code>precision</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>0</code> </td> <td class="description last">the precision number</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> </dd> </dl> <h4 class="name" id="round"><span class="type-signature"></span>round<span class="signature">(n, precision<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line324">line 324</a> </li></ul></dd> </dl> <div class="description"> rounds a value </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log((5.007).round()); // 5 console.log((5.007).round(2)); // 5.01 console.log((5070).round(-2)); // 5100</code></pre> <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>n</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the number</td> </tr> <tr> <td class="name"><code>precision</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>0</code> </td> <td class="description last">the precision number</td> </tr> </tbody> </table> <h5>Returns:</h5> <dl class="param-type"> <dt> Type </dt> <dd> <span class="param-type"><a href="number.html">number</a></span> </dd> </dl> <h4 class="name" id="times"><span class="type-signature"></span>times<span class="signature">(n, iteratee, reverse<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line70">line 70</a> </li></ul></dd> </dl> <div class="description"> repeats a function n times </div> <h5>Examples</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>(5).times(function(i) { console.log(i); }); // logs 1, 2, 3, 4, 5</code></pre> <p class="code-caption">or</p> <pre class="prettyprint"><code>(5).times(function(i) { console.log(i); }, true); // logs 5, 4, 3, 2, 1</code></pre> <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>n</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the number of times</td> </tr> <tr> <td class="name"><code>iteratee</code></td> <td class="type"> <span class="param-type"><a href="function.html">function</a></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">the iteratee function to invoke<br> the iteratee will be invoked passing the index as i<br> so the iteratee has to be something like this<br> <pre> function(i) {} </pre> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>i</code></td> <td class="type"> <span class="param-type"><a href="number.html">number</a></span> </td> <td class="description last">the index</td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name"><code>reverse</code></td> <td class="type"> <span class="param-type"><a href="boolean.html">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> <code>false</code> </td> <td class="description last">true if you want to do a times reverse cycle</td> </tr> </tbody> </table> <h4 class="name" id="toAbsolute"><span class="type-signature"></span>toAbsolute<span class="signature">(n)</span><span class="type-signature"> &rarr; {<a href="number.html">number</a>}</span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Extensions_number.js.html">Extensions/number.js</a>, <a href="Extensions_number.js.html#line185">line 185</a> </li></ul></dd> </dl> <div class="description"> absolutes a number </div> <h5>Example</h5> <p class="code-caption">eg. usage</p> <pre class="prettyprint"><code>console.log((1).toAbsolute()); // 1 console.log((1.56).toAbsolute()); // 1.56 console.log((-1.56).toAbsolute()); // 1.56</code></pre> <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>n</code></td> <td class="type">