Skip to content

Commit

Permalink
feat(isascii): now accepts integers with string type
Browse files Browse the repository at this point in the history
  • Loading branch information
LCluber committed Aug 9, 2019
1 parent 905a5b8 commit 140eba3
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion dist/ch.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var Ch = (function (exports) {
}
function isAscii(code, extended) {
if (extended === void 0) { extended = true; }
if (isInteger(code)) {
if (isInteger(code, false)) {
return (extended && code >= 0 && code <= 255) || (code >= 0 && code <= 127);
}
return false;
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.

2 changes: 1 addition & 1 deletion dist/ch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function isArray(array) {
}
function isAscii(code, extended) {
if (extended === void 0) { extended = true; }
if (isInteger(code)) {
if (isInteger(code, false)) {
return (extended && code >= 0 && code <= 255) || (code >= 0 && code <= 127);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/ts/ch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function isArray(array: any): boolean {
}

function isAscii(code: any, extended: boolean = true): boolean {
if (isInteger(code)) {
if (isInteger(code, false)) {
return (extended && code >= 0 && code <= 255) || (code >= 0 && code <= 127);
}
return false;
Expand Down
16 changes: 8 additions & 8 deletions tests/coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1565381213027" clover="3.2.0">
<project timestamp="1565381213027" name="All files">
<coverage generated="1565384094224" clover="3.2.0">
<project timestamp="1565384094224" name="All files">
<metrics statements="39" coveredstatements="39" conditionals="138" coveredconditionals="108" methods="18" coveredmethods="18" elements="195" coveredelements="165" complexity="0" loc="39" ncloc="39" packages="1" files="1" classes="1"/>
<file name="ch.js" path="/Users/lcluber/Projects/github/Ch.js/dist/ch.js">
<metrics statements="39" coveredstatements="39" conditionals="138" coveredconditionals="108" methods="18" coveredmethods="18"/>
Expand All @@ -17,13 +17,13 @@
<line num="33" count="3" type="stmt"/>
<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="30" type="cond" truecount="2" falsecount="0"/>
<line num="44" count="14" type="cond" truecount="5" falsecount="0"/>
<line num="42" count="32" type="cond" truecount="2" falsecount="0"/>
<line num="43" count="32" type="cond" truecount="2" falsecount="0"/>
<line num="44" count="16" type="cond" truecount="5" falsecount="0"/>
<line num="46" count="16" type="stmt"/>
<line num="49" count="135" type="cond" truecount="2" falsecount="0"/>
<line num="50" count="135" type="stmt"/>
<line num="51" count="135" type="cond" truecount="2" falsecount="0"/>
<line num="49" count="137" type="cond" truecount="2" falsecount="0"/>
<line num="50" count="137" type="stmt"/>
<line num="51" count="137" type="cond" truecount="2" falsecount="0"/>
<line num="54" count="57" type="cond" truecount="2" falsecount="0"/>
<line num="55" count="57" type="stmt"/>
<line num="56" count="57" type="cond" truecount="2" falsecount="0"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/coverage-final.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions tests/coverage/lcov-report/ch.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,16 @@ <h1>
<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">30x</span>
<span class="cline-any cline-yes">30x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-yes">32x</span>
<span class="cline-any cline-yes">32x</span>
<span class="cline-any cline-yes">16x</span>
<span class="cline-any cline-neutral">&nbsp;</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">135x</span>
<span class="cline-any cline-yes">135x</span>
<span class="cline-any cline-yes">135x</span>
<span class="cline-any cline-yes">137x</span>
<span class="cline-any cline-yes">137x</span>
<span class="cline-any cline-yes">137x</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-neutral">&nbsp;</span>
<span class="cline-any cline-yes">57x</span>
Expand Down Expand Up @@ -454,7 +454,7 @@ <h1>
}
function isAscii(code, extended) {
if (extended === void 0) { extended = true; }
if (isInteger(code)) {
if (isInteger(code, false)) {
return (extended &amp;&amp; code &gt;= 0 &amp;&amp; code &lt;= 255) || (code &gt;= 0 &amp;&amp; code &lt;= 127);
}
return false;
Expand Down Expand Up @@ -601,7 +601,7 @@ <h1>
</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 Fri Aug 09 2019 22:06:52 GMT+0200 (Central European Summer Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Aug 09 2019 22:54:54 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion tests/coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h1>
</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 Fri Aug 09 2019 22:06:52 GMT+0200 (Central European Summer Time)
generated by <a href="https://istanbul.js.org/" target="_blank">istanbul</a> at Fri Aug 09 2019 22:54:54 GMT+0200 (Central European Summer Time)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
38 changes: 19 additions & 19 deletions tests/coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ FNDA:19,isJson
FNDA:19,isFunction
FNDA:19,isObject
FNDA:24,isArray
FNDA:30,isAscii
FNDA:135,isInteger
FNDA:32,isAscii
FNDA:137,isInteger
FNDA:57,isFloat
FNDA:38,isNumber
FNDA:38,isString
Expand All @@ -51,13 +51,13 @@ DA:31,16
DA:33,3
DA:36,19
DA:39,24
DA:42,30
DA:43,30
DA:44,14
DA:42,32
DA:43,32
DA:44,16
DA:46,16
DA:49,135
DA:50,135
DA:51,135
DA:49,137
DA:50,137
DA:51,137
DA:54,57
DA:55,57
DA:56,57
Expand Down Expand Up @@ -90,19 +90,19 @@ BRDA:36,3,1,18
BRDA:36,3,2,5
BRDA:39,4,0,24
BRDA:39,4,1,23
BRDA:42,5,0,19
BRDA:42,5,0,21
BRDA:42,5,1,11
BRDA:43,6,0,14
BRDA:43,6,0,16
BRDA:43,6,1,16
BRDA:44,7,0,14
BRDA:44,7,1,7
BRDA:44,7,2,5
BRDA:44,7,3,10
BRDA:44,7,4,6
BRDA:49,8,0,130
BRDA:49,8,1,5
BRDA:51,9,0,130
BRDA:51,9,1,5
BRDA:44,7,0,16
BRDA:44,7,1,9
BRDA:44,7,2,7
BRDA:44,7,3,11
BRDA:44,7,4,7
BRDA:49,8,0,100
BRDA:49,8,1,37
BRDA:51,9,0,100
BRDA:51,9,1,37
BRDA:54,10,0,52
BRDA:54,10,1,5
BRDA:56,11,0,52
Expand Down
8 changes: 8 additions & 0 deletions tests/isascii.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ test("sends string to isAscii extended", () => {
expect(Ch.isAscii("string")).toBe(false);
});

test("sends number as string to isAscii extended", () => {
expect(Ch.isAscii("2")).toBe(true);
});

test("sends 256 as string to isAscii extended", () => {
expect(Ch.isAscii("256")).toBe(false);
});

test("sends positive even integer to isAscii not extended", () => {
expect(Ch.isAscii(2, false)).toBe(true);
});
Expand Down

0 comments on commit 140eba3

Please sign in to comment.