Travis build: 43

This commit is contained in:
Pl4gue
2017-12-21 15:39:03 +00:00
parent a4bd86ba71
commit bafebfb86c
2 changed files with 35 additions and 0 deletions

View File

@ -150,6 +150,7 @@
* [`isSymbol`](#issymbol)
* [`RGBToHex`](#rgbtohex)
* [`timeTaken`](#timetaken)
* [`toDecimalMark`](#todecimalmark)
* [`toOrdinalSuffix`](#toordinalsuffix)
* [`UUIDGenerator`](#uuidgenerator)
* [`validateEmail`](#validateemail)
@ -2091,6 +2092,26 @@ const timeTaken = callback => {
[⬆ back to top](#table-of-contents)
### toDecimalMark
Convert a float-point arithmetic to the [Decimal mark](https://en.wikipedia.org/wiki/Decimal_mark) form.
Use `toString()` to convert the float `num` to a string, then use regex to separate every three characters of the integer part with a comma.
```js
const toDecimalMark = (num) => {
let cleanNum = num.toString().split('').filter(n => '0123456789.'.includes(n)).join('')
let wholeNum = cleanNum.split('.')[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",")
let decNum = `.${cleanNum.split('.')[1]}`
return wholeNum + decNum;
}
// toDecimalMark(12305030388.9087) //-> '12,305,030,388.9087'
// toDecimalMark(123.889087e2) //-> '12,388.9087'
// toDecimalMark('12305abc030388.9087') // -> '12,305,030,388.9087'
```
[⬆ back to top](#table-of-contents)
### toOrdinalSuffix
Adds an ordinal suffix to a number.

View File

@ -181,6 +181,7 @@
<a class="sublink-1" href="#issymbol">isSymbol</a>
<a class="sublink-1" href="#rgbtohex">RGBToHex</a>
<a class="sublink-1" href="#timetaken">timeTaken</a>
<a class="sublink-1" href="#todecimalmark">toDecimalMark</a>
<a class="sublink-1" href="#toordinalsuffix">toOrdinalSuffix</a>
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a>
<a class="sublink-1" href="#validateemail">validateEmail</a>
@ -1270,6 +1271,19 @@ Omit the second argument to use the default regex.</p>
// timeTaken(() =&gt; Math.pow(2, 10)) -&gt; 1024
// (logged): timeTaken: 0.02099609375ms
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="todecimalmark">toDecimalMark</h3></div><div class="section double-padded">
<p>Convert a float-point arithmetic to the <a href="https://en.wikipedia.org/wiki/Decimal_mark">Decimal mark</a> form.</p>
<p>Use <code>toString()</code> to convert the float <code>num</code> to a string, then use regex to separate every three characters of the integer part with a comma.</p>
<pre><code class="language-js">const toDecimalMark = (num) =&gt; {
let cleanNum = num.toString().split('').filter(n =&gt; '0123456789.'.includes(n)).join('')
let wholeNum = cleanNum.split('.')[0].replace(/\B(?=(\d{3})+(?!\d))/g, &quot;,&quot;)
let decNum = `.${cleanNum.split('.')[1]}`
return wholeNum + decNum;
}
// toDecimalMark(12305030388.9087) //-&gt; '12,305,030,388.9087'
// toDecimalMark(123.889087e2) //-&gt; '12,388.9087'
// toDecimalMark('12305abc030388.9087') // -&gt; '12,305,030,388.9087'
</code></pre>
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="toordinalsuffix">toOrdinalSuffix</h3></div><div class="section double-padded">
<p>Adds an ordinal suffix to a number.</p>
<p>Use the modulo operator (<code>%</code>) to find values of single and tens digits.