Skip to content

Commit

Permalink
Convert MessageParser to ES6 class
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Feb 10, 2019
1 parent 84a8035 commit fafc7ed
Show file tree
Hide file tree
Showing 2 changed files with 340 additions and 131 deletions.
207 changes: 207 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ <h3 class='mb0 no-anchor'>tuyapi</h3>

</li>


<li><a
href='#parse'
class="">
parse

</a>

</li>


<li><a
href='#encode'
class="">
encode

</a>

</li>

</ul>
</div>
<div class='mt1 h6 quiet'>
Expand Down Expand Up @@ -1244,6 +1264,193 @@ <h3 class='fl m0' id='eventtuyadevicedisconnected'>









</section>



<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='parse'>
parse
</h3>


</div>


<p>Static wrapper for lower-level MessageParser
functions to easily parse packets.</p>



<div class='pre p1 fill-light mt0'>parse(data: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>












<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>
packet to parse

</div>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
result



<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>:
result.data decoded data, if available in response



<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>:
result.commandByte command byte from decoded data














</section>



<section class='p2 mb2 clearfix bg-white minishadow'>


<div class='clearfix'>

<h3 class='fl m0' id='encode'>
encode
</h3>


</div>


<p>Static wrapper for lower-level MessageParser
functions to easily encode packets</p>



<div class='pre p1 fill-light mt0'>encode(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://nodejs.org/api/buffer.html">Buffer</a></div>












<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>

</div>

<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
</td>
<td class='break-word'><span>data to encode
</span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.commandByte</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
</td>
<td class='break-word'><span>command byte
</span></td>
</tr>



</tbody>
</table>

</div>

</div>






<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code>:
binary payload











Expand Down
Loading

0 comments on commit fafc7ed

Please sign in to comment.