Skip to content

Commit

Permalink
exept let in parseData
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLiVa committed Jul 2, 2024
1 parent 53bedfd commit e9369a1
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 86 deletions.
32 changes: 14 additions & 18 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1719920944217" clover="3.2.0">
<project timestamp="1719920944217" name="All files">
<metrics statements="206" coveredstatements="206" conditionals="53" coveredconditionals="53" methods="14" coveredmethods="14" elements="273" coveredelements="273" complexity="0" loc="206" ncloc="206" packages="2" files="7" classes="7"/>
<coverage generated="1719921997148" clover="3.2.0">
<project timestamp="1719921997148" name="All files">
<metrics statements="202" coveredstatements="202" conditionals="52" coveredconditionals="52" methods="14" coveredmethods="14" elements="268" coveredelements="268" complexity="0" loc="202" ncloc="202" packages="2" files="7" classes="7"/>
<package name="src">
<metrics statements="88" coveredstatements="88" conditionals="19" coveredconditionals="19" methods="7" coveredmethods="7"/>
<metrics statements="84" coveredstatements="84" conditionals="18" coveredconditionals="18" methods="7" coveredmethods="7"/>
<file name="buildTree.js" path="/home/username_bolivarli/frontend-project-46/src/buildTree.js">
<metrics statements="42" coveredstatements="42" conditionals="9" coveredconditionals="9" methods="2" coveredmethods="2"/>
<line num="1" count="1" type="stmt"/>
Expand Down Expand Up @@ -80,26 +80,22 @@
<line num="27" count="1" type="stmt"/>
</file>
<file name="parser.js" path="/home/username_bolivarli/frontend-project-46/src/parser.js">
<metrics statements="19" coveredstatements="19" conditionals="6" coveredconditionals="6" methods="1" coveredmethods="1"/>
<metrics statements="15" coveredstatements="15" conditionals="5" coveredconditionals="5" methods="1" coveredmethods="1"/>
<line num="1" count="1" type="stmt"/>
<line num="2" count="1" type="stmt"/>
<line num="3" count="1" type="cond" truecount="1" falsecount="0"/>
<line num="4" count="15" type="stmt"/>
<line num="5" count="15" type="stmt"/>
<line num="6" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="7" count="8" type="stmt"/>
<line num="8" count="8" type="stmt"/>
<line num="9" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="5" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="6" count="8" type="stmt"/>
<line num="7" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="8" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="9" count="6" type="stmt"/>
<line num="10" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="11" count="6" type="stmt"/>
<line num="12" count="6" type="stmt"/>
<line num="13" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="11" count="1" type="stmt"/>
<line num="12" count="15" type="stmt"/>
<line num="13" count="15" type="stmt"/>
<line num="14" count="1" type="stmt"/>
<line num="15" count="15" type="cond" truecount="1" falsecount="0"/>
<line num="16" count="14" type="stmt"/>
<line num="17" count="14" type="stmt"/>
<line num="18" count="1" type="stmt"/>
<line num="19" count="1" type="stmt"/>
<line num="15" count="1" type="stmt"/>
</file>
</package>
<package name="src.formatters">
Expand Down
2 changes: 1 addition & 1 deletion coverage/coverage-final.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h1>All files</h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>206/206</span>
<span class='fraction'>202/202</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>53/53</span>
<span class='fraction'>52/52</span>
</div>


Expand All @@ -46,7 +46,7 @@ <h1>All files</h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>206/206</span>
<span class='fraction'>202/202</span>
</div>


Expand Down Expand Up @@ -84,13 +84,13 @@ <h1>All files</h1>
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="88" class="abs high">88/88</td>
<td data-value="84" class="abs high">84/84</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="19" class="abs high">19/19</td>
<td data-value="18" class="abs high">18/18</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="7" class="abs high">7/7</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="88" class="abs high">88/88</td>
<td data-value="84" class="abs high">84/84</td>
</tr>

<tr>
Expand All @@ -116,7 +116,7 @@ <h1>All files</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/buildTree.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> buildTr
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/formatters/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ <h1><a href="../../index.html">All files</a> src/formatters</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/formatters/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h1><a href="../../index.html">All files</a> / <a href="index.html">src/formatte
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/formatters/json.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h1><a href="../../index.html">All files</a> / <a href="index.html">src/formatte
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/formatters/plain.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ <h1><a href="../../index.html">All files</a> / <a href="index.html">src/formatte
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/formatters/stylish.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ <h1><a href="../../index.html">All files</a> / <a href="index.html">src/formatte
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
14 changes: 7 additions & 7 deletions coverage/lcov-report/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>88/88</span>
<span class='fraction'>84/84</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>19/19</span>
<span class='fraction'>18/18</span>
</div>


Expand All @@ -46,7 +46,7 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>88/88</span>
<span class='fraction'>84/84</span>
</div>


Expand Down Expand Up @@ -114,13 +114,13 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="19" class="abs high">19/19</td>
<td data-value="15" class="abs high">15/15</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="6" class="abs high">6/6</td>
<td data-value="5" class="abs high">5/5</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="1" class="abs high">1/1</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="19" class="abs high">19/19</td>
<td data-value="15" class="abs high">15/15</td>
</tr>

</tbody>
Expand All @@ -131,7 +131,7 @@ <h1><a href="../index.html">All files</a> src</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> index.j
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
28 changes: 8 additions & 20 deletions coverage/lcov-report/src/parser.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> parser.
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>19/19</span>
<span class='fraction'>15/15</span>
</div>


<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>6/6</span>
<span class='fraction'>5/5</span>
</div>


Expand All @@ -46,7 +46,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> parser.
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>19/19</span>
<span class='fraction'>15/15</span>
</div>


Expand Down Expand Up @@ -78,45 +78,33 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> parser.
<a name='L13'></a><a href='#L13'>13</a>
<a name='L14'></a><a href='#L14'>14</a>
<a name='L15'></a><a href='#L15'>15</a>
<a name='L16'></a><a href='#L16'>16</a>
<a name='L17'></a><a href='#L17'>17</a>
<a name='L18'></a><a href='#L18'>18</a>
<a name='L19'></a><a href='#L19'>19</a>
<a name='L20'></a><a href='#L20'>20</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<a name='L16'></a><a href='#L16'>16</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-yes">8x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">6x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-yes">15x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-yes">1x</span>
<span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import yaml from 'js-yaml';
&nbsp;
const parseData = (data, format) =&gt; {
let parsedData;
switch (format) {
case '.json':
parsedData = JSON.parse(data);
break;
return JSON.parse(data);
case '.yml':
case '.yaml':
parsedData = yaml.load(data);
break;
return yaml.load(data);
default:
throw new Error(`Unknown format: ${format}`);
}
return parsedData;
};
&nbsp;
export default parseData;
Expand All @@ -127,7 +115,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> parser.
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2024-07-02T11:49:04.205Z
at 2024-07-02T12:06:37.132Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
35 changes: 15 additions & 20 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,25 @@ DA:2,1
DA:3,1
DA:4,15
DA:5,15
DA:6,15
DA:7,8
DA:8,8
DA:9,15
DA:6,8
DA:7,15
DA:8,15
DA:9,6
DA:10,15
DA:11,6
DA:12,6
DA:11,1
DA:12,15
DA:13,15
DA:14,1
DA:15,15
DA:16,14
DA:17,14
DA:18,1
DA:19,1
LF:19
LH:19
DA:15,1
LF:15
LH:15
BRDA:3,0,0,15
BRDA:6,1,0,8
BRDA:9,2,0,6
BRDA:10,3,0,6
BRDA:13,4,0,1
BRDA:15,5,0,14
BRF:6
BRH:6
BRDA:5,1,0,8
BRDA:7,2,0,6
BRDA:8,3,0,6
BRDA:10,4,0,1
BRF:5
BRH:5
end_of_record
TN:
SF:src/formatters/index.js
Expand Down
8 changes: 2 additions & 6 deletions src/parser.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import yaml from 'js-yaml';

const parseData = (data, format) => {
let parsedData;
switch (format) {
case '.json':
parsedData = JSON.parse(data);
break;
return JSON.parse(data);
case '.yml':
case '.yaml':
parsedData = yaml.load(data);
break;
return yaml.load(data);
default:
throw new Error(`Unknown format: ${format}`);
}
return parsedData;
};

export default parseData;

0 comments on commit e9369a1

Please sign in to comment.