Skip to content

Commit

Permalink
feat(numbers): added isEven, isOdd, isOrigin, isPositive, isNegative
Browse files Browse the repository at this point in the history
added isEven, isOdd, isOrigin, isPositive, isNegative methods
  • Loading branch information
LCluber committed Jul 21, 2019
1 parent 075aee5 commit 61db1c5
Show file tree
Hide file tree
Showing 28 changed files with 1,061 additions and 158 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ isFloat(number: any): boolean {}
isNumber(number: any): boolean {}

isString(string: any): boolean {}

isEven(number: any): boolean {}

isOdd(number: any): boolean {}

isOrigin(number: any): boolean {}

isPositive(number: any): boolean {}

isNegative(number: any): boolean {}
```

## Contributors
Expand Down
7 changes: 6 additions & 1 deletion dist/ch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ declare function isNumber(number: any): boolean;
declare function isString(string: any): boolean;
declare function isHtmlElement(htmlElement: any): boolean;
declare function isNode(node: any): boolean;
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode };
declare function isEven(number: any): boolean;
declare function isOdd(number: any): boolean;
declare function isOrigin(number: any): boolean;
declare function isPositive(number: any): boolean;
declare function isNegative(number: any): boolean;
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode, isEven, isOdd, isOrigin, isPositive, isNegative };
20 changes: 20 additions & 0 deletions dist/ch.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,38 @@ var Ch = (function (exports) {
}
return false;
}
function isEven(number) {
return isInteger(number) && !(number & 1);
}
function isOdd(number) {
return isInteger(number) && number & 1 ? true : false;
}
function isOrigin(number) {
return number === 0 ? true : false;
}
function isPositive(number) {
return isNumber(number) && number > 0 ? true : false;
}
function isNegative(number) {
return number < 0 ? true : false;
}

exports.isArray = isArray;
exports.isAscii = isAscii;
exports.isBoolean = isBoolean;
exports.isEven = isEven;
exports.isFloat = isFloat;
exports.isFunction = isFunction;
exports.isHtmlElement = isHtmlElement;
exports.isInteger = isInteger;
exports.isJson = isJson;
exports.isNegative = isNegative;
exports.isNode = isNode;
exports.isNumber = isNumber;
exports.isObject = isObject;
exports.isOdd = isOdd;
exports.isOrigin = isOrigin;
exports.isPositive = isPositive;
exports.isString = isString;

return exports;
Expand Down
2 changes: 1 addition & 1 deletion dist/ch.iife.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion dist/ch.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ function isNode(node) {
}
return false;
}
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode };
function isEven(number) {
return isInteger(number) && !(number & 1);
}
function isOdd(number) {
return isInteger(number) && number & 1 ? true : false;
}
function isOrigin(number) {
return number === 0 ? true : false;
}
function isPositive(number) {
return isNumber(number) && number > 0 ? true : false;
}
function isNegative(number) {
return number < 0 ? true : false;
}
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode, isEven, isOdd, isOrigin, isPositive, isNegative };
27 changes: 26 additions & 1 deletion src/ts/ch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ function isNode(node: any): boolean {
return false;
}

function isEven(number: any): boolean {
return isInteger(number) && !(number & 1);
}

function isOdd(number: any): boolean {
return isInteger(number) && number & 1 ? true : false;
}

function isOrigin(number: any): boolean {
return number === 0 ? true : false;
}

function isPositive(number: any): boolean {
return isNumber(number) && number > 0 ? true : false;
}

function isNegative(number: any): boolean {
return number < 0 ? true : false;
}

export {
isBoolean,
isJson,
Expand All @@ -93,5 +113,10 @@ export {
isNumber,
isString,
isHtmlElement,
isNode
isNode,
isEven,
isOdd,
isOrigin,
isPositive,
isNegative
};
51 changes: 28 additions & 23 deletions tests/coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1563313172413" clover="3.2.0">
<project timestamp="1563313172413" name="All files">
<metrics statements="26" coveredstatements="26" conditionals="39" coveredconditionals="37" methods="12" coveredmethods="12" elements="77" coveredelements="75" complexity="0" loc="26" ncloc="26" packages="1" files="1" classes="1"/>
<coverage generated="1563710561979" clover="3.2.0">
<project timestamp="1563710561979" name="All files">
<metrics statements="31" coveredstatements="31" conditionals="53" coveredconditionals="51" methods="17" coveredmethods="17" elements="101" coveredelements="99" complexity="0" loc="31" ncloc="31" packages="1" files="1" classes="1"/>
<file name="ch.js" path="/Users/lcluber/Projects/github/Ch.js/dist/ch.js">
<metrics statements="26" coveredstatements="26" conditionals="39" coveredconditionals="37" methods="12" coveredmethods="12"/>
<line num="14" count="15" type="stmt"/>
<line num="17" count="15" type="cond" truecount="2" falsecount="0"/>
<line num="18" count="12" type="stmt"/>
<metrics statements="31" coveredstatements="31" conditionals="53" coveredconditionals="51" methods="17" coveredmethods="17"/>
<line num="14" count="19" type="stmt"/>
<line num="17" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="18" count="16" type="stmt"/>
<line num="20" count="3" type="stmt"/>
<line num="21" count="3" type="stmt"/>
<line num="24" count="2" type="stmt"/>
<line num="26" count="1" type="stmt"/>
<line num="29" count="15" type="cond" truecount="2" falsecount="0"/>
<line num="30" count="12" type="stmt"/>
<line num="31" count="12" type="cond" truecount="2" falsecount="0"/>
<line num="29" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="30" count="16" type="stmt"/>
<line num="31" count="16" type="cond" truecount="2" falsecount="0"/>
<line num="33" count="3" type="stmt"/>
<line num="36" count="15" type="cond" truecount="3" falsecount="0"/>
<line num="39" count="20" type="cond" truecount="2" falsecount="0"/>
<line num="42" count="18" type="cond" truecount="2" falsecount="0"/>
<line num="43" count="5" type="cond" truecount="5" falsecount="0"/>
<line num="45" count="13" type="stmt"/>
<line num="48" count="48" type="stmt"/>
<line num="51" count="28" type="cond" truecount="2" falsecount="0"/>
<line num="54" count="15" type="cond" truecount="2" falsecount="0"/>
<line num="57" count="30" type="stmt"/>
<line num="60" count="15" type="cond" truecount="2" falsecount="0"/>
<line num="61" count="12" type="cond" truecount="1" falsecount="1"/>
<line num="36" count="19" type="cond" truecount="3" falsecount="0"/>
<line num="39" count="24" type="cond" truecount="2" falsecount="0"/>
<line num="42" count="30" type="cond" truecount="2" falsecount="0"/>
<line num="43" count="14" type="cond" truecount="5" falsecount="0"/>
<line num="45" count="16" type="stmt"/>
<line num="48" count="125" type="stmt"/>
<line num="51" count="47" type="cond" truecount="2" falsecount="0"/>
<line num="54" count="38" type="cond" truecount="2" falsecount="0"/>
<line num="57" count="38" type="stmt"/>
<line num="60" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="61" count="16" type="cond" truecount="1" falsecount="1"/>
<line num="69" count="3" type="stmt"/>
<line num="72" count="15" type="cond" truecount="2" falsecount="0"/>
<line num="73" count="12" type="cond" truecount="1" falsecount="1"/>
<line num="72" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="73" count="16" type="cond" truecount="1" falsecount="1"/>
<line num="80" count="3" type="stmt"/>
<line num="83" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="86" count="19" type="cond" truecount="4" falsecount="0"/>
<line num="89" count="19" type="cond" truecount="2" falsecount="0"/>
<line num="92" count="19" type="cond" truecount="4" falsecount="0"/>
<line num="95" count="19" type="cond" truecount="2" falsecount="0"/>
</file>
</project>
</coverage>
2 changes: 1 addition & 1 deletion tests/coverage/coverage-final.json

Large diffs are not rendered by default.

99 changes: 72 additions & 27 deletions tests/coverage/lcov-report/ch.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>26/26</span>
<span class='fraction'>31/31</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">94.87% </span>
<span class="strong">96.23% </span>
<span class="quiet">Branches</span>
<span class='fraction'>37/39</span>
<span class='fraction'>51/53</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>12/12</span>
<span class='fraction'>17/17</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>26/26</span>
<span class='fraction'>31/31</span>
</div>
</div>
<p class="quiet">
Expand Down Expand Up @@ -128,7 +128,22 @@ <h1>
<a name='L80'></a><a href='#L80'>80</a>
<a name='L81'></a><a href='#L81'>81</a>
<a name='L82'></a><a href='#L82'>82</a>
<a name='L83'></a><a href='#L83'>83</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<a name='L83'></a><a href='#L83'>83</a>
<a name='L84'></a><a href='#L84'>84</a>
<a name='L85'></a><a href='#L85'>85</a>
<a name='L86'></a><a href='#L86'>86</a>
<a name='L87'></a><a href='#L87'>87</a>
<a name='L88'></a><a href='#L88'>88</a>
<a name='L89'></a><a href='#L89'>89</a>
<a name='L90'></a><a href='#L90'>90</a>
<a name='L91'></a><a href='#L91'>91</a>
<a name='L92'></a><a href='#L92'>92</a>
<a name='L93'></a><a href='#L93'>93</a>
<a name='L94'></a><a href='#L94'>94</a>
<a name='L95'></a><a href='#L95'>95</a>
<a name='L96'></a><a href='#L96'>96</a>
<a name='L97'></a><a href='#L97'>97</a>
<a name='L98'></a><a href='#L98'>98</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -141,11 +156,11 @@ <h1>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">12x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-yes">3x</span>
Expand All @@ -156,39 +171,39 @@ <h1>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">12x</span>
<span class="cline-any cline-yes">12x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">20x</span>
<span class="cline-any cline-yes">24x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">18x</span>
<span class="cline-any cline-yes">5x</span>
<span class="cline-any cline-yes">30x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">13x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">48x</span>
<span class="cline-any cline-yes">125x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">47x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">38x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">30x</span>
<span class="cline-any cline-yes">38x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">12x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -199,8 +214,8 @@ <h1>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">12x</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
Expand All @@ -210,6 +225,21 @@ <h1>
<span class="cline-any cline-yes">3x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">19x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/* MIT License
&nbsp;
Copyright (c) 2009 Ludovic CLUBER
Expand Down Expand Up @@ -291,14 +321,29 @@ <h1>
}
return false;
}
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode };
function isEven(number) {
return isInteger(number) &amp;&amp; !(number &amp; 1);
}
function isOdd(number) {
return isInteger(number) &amp;&amp; number &amp; 1 ? true : false;
}
function isOrigin(number) {
return number === 0 ? true : false;
}
function isPositive(number) {
return isNumber(number) &amp;&amp; number &gt; 0 ? true : false;
}
function isNegative(number) {
return number &lt; 0 ? true : false;
}
export { isBoolean, isJson, isFunction, isObject, isArray, isAscii, isInteger, isFloat, isNumber, isString, isHtmlElement, isNode, isEven, isOdd, isOrigin, isPositive, isNegative };
&nbsp;</pre></td></tr>
</table></pre>
<div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Tue Jul 16 2019 23:39:32 GMT+0200 (Central European Summer Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Sun Jul 21 2019 14:02:41 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
Loading

0 comments on commit 61db1c5

Please sign in to comment.