Skip to content

Commit

Permalink
change buildTree
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLiVa committed Jul 2, 2024
1 parent 4a1fb93 commit 1f1ff90
Show file tree
Hide file tree
Showing 16 changed files with 152 additions and 179 deletions.
53 changes: 22 additions & 31 deletions coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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"/>
<coverage generated="1719930374642" clover="3.2.0">
<project timestamp="1719930374642" name="All files">
<metrics statements="193" coveredstatements="193" conditionals="52" coveredconditionals="52" methods="14" coveredmethods="14" elements="259" coveredelements="259" complexity="0" loc="193" ncloc="193" packages="2" files="7" classes="7"/>
<package name="src">
<metrics statements="84" coveredstatements="84" conditionals="18" coveredconditionals="18" methods="7" coveredmethods="7"/>
<metrics statements="75" coveredstatements="75" 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"/>
<metrics statements="33" coveredstatements="33" conditionals="9" coveredconditionals="9" methods="2" coveredmethods="2"/>
<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"/>
Expand All @@ -15,39 +15,30 @@
<line num="7" count="35" type="stmt"/>
<line num="8" count="35" type="cond" truecount="1" falsecount="0"/>
<line num="9" count="126" type="stmt"/>
<line num="10" count="126" type="stmt"/>
<line num="11" count="126" type="stmt"/>
<line num="10" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="11" count="14" type="stmt"/>
<line num="12" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="13" count="14" type="stmt"/>
<line num="14" count="14" type="stmt"/>
<line num="15" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="16" count="35" type="stmt"/>
<line num="17" count="35" type="stmt"/>
<line num="18" count="126" type="cond" truecount="2" falsecount="0"/>
<line num="13" count="35" type="stmt"/>
<line num="14" count="126" type="cond" truecount="2" falsecount="0"/>
<line num="15" count="28" type="stmt"/>
<line num="16" count="28" type="stmt"/>
<line num="17" count="28" type="stmt"/>
<line num="18" count="28" type="stmt"/>
<line num="19" count="28" type="stmt"/>
<line num="20" count="28" type="stmt"/>
<line num="20" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="21" count="28" type="stmt"/>
<line num="22" count="28" type="stmt"/>
<line num="23" count="28" type="stmt"/>
<line num="24" count="28" type="stmt"/>
<line num="25" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="25" count="28" type="stmt"/>
<line num="26" count="28" type="stmt"/>
<line num="27" count="28" type="stmt"/>
<line num="28" count="28" type="stmt"/>
<line num="29" count="28" type="stmt"/>
<line num="30" count="28" type="stmt"/>
<line num="31" count="28" type="stmt"/>
<line num="32" count="28" type="stmt"/>
<line num="33" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="34" count="21" type="stmt"/>
<line num="35" count="126" type="stmt"/>
<line num="36" count="126" type="stmt"/>
<line num="37" count="126" type="stmt"/>
<line num="38" count="126" type="stmt"/>
<line num="39" count="35" type="stmt"/>
<line num="40" count="35" type="stmt"/>
<line num="41" count="1" type="stmt"/>
<line num="42" count="1" type="stmt"/>
<line num="27" count="126" type="cond" truecount="1" falsecount="0"/>
<line num="28" count="21" type="stmt"/>
<line num="29" count="126" type="stmt"/>
<line num="30" count="35" type="stmt"/>
<line num="31" count="35" type="stmt"/>
<line num="32" count="1" type="stmt"/>
<line num="33" count="1" type="stmt"/>
</file>
<file name="index.js" path="/home/username_bolivarli/frontend-project-46/src/index.js">
<metrics statements="27" coveredstatements="27" conditionals="4" coveredconditionals="4" methods="4" coveredmethods="4"/>
Expand Down
2 changes: 1 addition & 1 deletion coverage/coverage-final.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>All files</h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>202/202</span>
<span class='fraction'>193/193</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'>202/202</span>
<span class='fraction'>193/193</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="84" class="abs high">84/84</td>
<td data-value="75" class="abs high">75/75</td>
<td data-value="100" class="pct high">100%</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="84" class="abs high">84/84</td>
<td data-value="75" class="abs high">75/75</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
49 changes: 11 additions & 38 deletions coverage/lcov-report/src/buildTree.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> buildTr
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>42/42</span>
<span class='fraction'>33/33</span>
</div>


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


Expand Down Expand Up @@ -96,16 +96,7 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> buildTr
<a name='L31'></a><a href='#L31'>31</a>
<a name='L32'></a><a href='#L32'>32</a>
<a name='L33'></a><a href='#L33'>33</a>
<a name='L34'></a><a href='#L34'>34</a>
<a name='L35'></a><a href='#L35'>35</a>
<a name='L36'></a><a href='#L36'>36</a>
<a name='L37'></a><a href='#L37'>37</a>
<a name='L38'></a><a href='#L38'>38</a>
<a name='L39'></a><a href='#L39'>39</a>
<a name='L40'></a><a href='#L40'>40</a>
<a name='L41'></a><a href='#L41'>41</a>
<a name='L42'></a><a href='#L42'>42</a>
<a name='L43'></a><a href='#L43'>43</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
<a name='L34'></a><a href='#L34'>34</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">1x</span>
Expand All @@ -115,34 +106,25 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> buildTr
<span class="cline-any cline-yes">35x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-yes">14x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">35x</span>
<span class="cline-any cline-yes">35x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">28x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">21x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">126x</span>
<span class="cline-any cline-yes">35x</span>
<span class="cline-any cline-yes">35x</span>
<span class="cline-any cline-yes">1x</span>
Expand All @@ -154,38 +136,29 @@ <h1><a href="../index.html">All files</a> / <a href="index.html">src</a> buildTr
const buildTree = (data1, data2) =&gt; {
const keys = getKey(data1, data2);
&nbsp;
return keys.reduce((acc, key) =&gt; {
let diffEntry;
&nbsp;
return keys.map((key) =&gt; {
switch (true) {
case !_.has(data2, key):
diffEntry = { key, type: 'removed', value: data1[key] };
break;
return { key, type: 'removed', value: data1[key] };
case !_.has(data1, key):
diffEntry = { key, type: 'added', value: data2[key] };
break;
return { key, type: 'added', value: data2[key] };
case _.isObject(data1[key]) &amp;&amp; _.isObject(data2[key]):
diffEntry = {
return {
key,
type: 'nested',
children: buildTree(data1[key], data2[key]),
};
break;
case !_.isEqual(data1[key], data2[key]):
diffEntry = {
return {
key,
type: 'updated',
oldValue: data1[key],
newValue: data2[key],
};
break;
default:
diffEntry = { key, type: 'unchanged', value: data1[key] };
return { key, type: 'unchanged', value: data1[key] };
}
&nbsp;
acc.push(diffEntry);
return acc;
}, []);
});
};
&nbsp;
export default buildTree;
Expand All @@ -196,7 +169,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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</div>
<script src="../../prettify.js"></script>
<script>
Expand Down
10 changes: 5 additions & 5 deletions coverage/lcov-report/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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">Statements</span>
<span class='fraction'>84/84</span>
<span class='fraction'>75/75</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'>84/84</span>
<span class='fraction'>75/75</span>
</div>


Expand Down Expand Up @@ -84,13 +84,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="42" class="abs high">42/42</td>
<td data-value="33" class="abs high">33/33</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="9" class="abs high">9/9</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="2" class="abs high">2/2</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="42" class="abs high">42/42</td>
<td data-value="33" class="abs high">33/33</td>
</tr>

<tr>
Expand Down Expand Up @@ -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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/src/parser.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,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-02T12:06:37.132Z
at 2024-07-02T14:26:14.628Z
</div>
<script src="../prettify.js"></script>
<script>
Expand Down
Loading

0 comments on commit 1f1ff90

Please sign in to comment.