Skip to content

Commit

Permalink
Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
GoToLoop committed Sep 7, 2023
1 parent 9f7f9f7 commit 22d0734
Show file tree
Hide file tree
Showing 28 changed files with 884 additions and 189 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ $RECYCLE.BIN/

node_modules
package-lock.json

coverage
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ evaluating `sqrt(tan(z))` leaving `z` unchanged.

In some situations, floating point errors can be significant. Testing for
equality or to see if the number represents a real value can be problematic.
By default, the maximum permitted difference is `10^-8`, but in some
By default, the maximum permitted difference is `10^-8`; but in some
situations, this may be too restrictive and reject values you wish to
consider equal. Use accessor `Complex.epsilon` to change the static
`#epsilon` property's default value.

> ⚠️ Notice that b/c `Complex.epsilon` is a static property, changing it affects
> ⚠️ Notice that b/c `Complex.epsilon` is a static accessor, changing it affects
all instances of class `Complex`. As a workaround, all methods which rely on it
accept an optional `epsilon` argument to be used in the test, thus ignoring the
global static value.
global static default value.

## Additional Information ℹ️

- Last updated: 16 Aug 2023
- Author: Peter Lager (2023)
- Refactored by GoToLoop
- Refactored by GoToLoop (2023)

- [Complex on GitHub](https://GitHub.com/GoToLoop/Complex)
- [Documentation](https://GoToLoop.GitHub.io/Complex)
14 changes: 14 additions & 0 deletions complex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

/**
* An immutable complex number class with real and imaginary parts.
* @name Complex
* @class Complex
*/
export default class Complex {
Expand Down Expand Up @@ -1018,6 +1019,7 @@ export default class Complex {
* @memberof Complex
* @instance
* @return {number} The absolute length value of this complex number.
* @description Alias of Complex::abs().
*/
Complex.prototype.mod = Complex.prototype.abs;

Expand All @@ -1027,9 +1029,21 @@ Complex.prototype.mod = Complex.prototype.abs;
* @memberof Complex
* @instance
* @return {number} The squared absolute value of this complex number.
* @description Alias of Complex::abs_squared().
*/
Complex.prototype.modSq = Complex.prototype.abs_squared;

/**
* Multiplies this complex number by another complex number or a scalar.
* @method mul
* @memberof Complex
* @instance
* @param {(Cobj | number)} n The multiplicand.
* @return {this} The product of the multiplication.
* @description Alias of Complex::mult().
*/
Complex.prototype.mul = Complex.prototype.mult;

// Freeze the Complex class to prevent further modifications to
// its static properties & methods:
Object.freeze(Complex);
172 changes: 167 additions & 5 deletions docs/jsdoc/Complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h4 class="name" id="mod"><span class="type-signature"></span>mod<span class="si


<div class="description">
Compute the absolute value (modulus or magnitude) of this complex number.
Alias of Complex::abs().
</div>


Expand Down Expand Up @@ -201,7 +201,7 @@ <h4 class="name" id="mod"><span class="type-signature"></span>mod<span class="si

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="complex.mjs.html">complex.mjs</a>, <a href="complex.mjs.html#line1015">line 1015</a>
<a href="complex.mjs.html">complex.mjs</a>, <a href="complex.mjs.html#line1016">line 1016</a>
</li></ul></dd>


Expand Down Expand Up @@ -267,7 +267,7 @@ <h4 class="name" id="modSq"><span class="type-signature"></span>modSq<span class


<div class="description">
Compute the squared absolute value of this complex number.
Alias of Complex::abs_squared().
</div>


Expand Down Expand Up @@ -311,7 +311,7 @@ <h4 class="name" id="modSq"><span class="type-signature"></span>modSq<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="complex.mjs.html">complex.mjs</a>, <a href="complex.mjs.html#line1024">line 1024</a>
<a href="complex.mjs.html">complex.mjs</a>, <a href="complex.mjs.html#line1026">line 1026</a>
</li></ul></dd>


Expand Down Expand Up @@ -364,6 +364,168 @@ <h5>Returns:</h5>








<h4 class="name" id="mul"><span class="type-signature"></span>mul<span class="signature">(n)</span><span class="type-signature"> &rarr; {this}</span></h4>






<div class="description">
Alias of Complex::mult().
</div>









<h5>Parameters:</h5>


<table class="params">
<thead>
<tr>

<th>Name</th>


<th>Type</th>





<th class="last">Description</th>
</tr>
</thead>

<tbody>


<tr>

<td class="name"><code>n</code></td>


<td class="type">


<span class="param-type"><a href="global.html#Cobj">Cobj</a></span>
|

<span class="param-type">number</span>



</td>





<td class="description last">The multiplicand.</td>
</tr>


</tbody>
</table>






<dl class="details">


























<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="complex.mjs.html">complex.mjs</a>, <a href="complex.mjs.html#line1036">line 1036</a>
</li></ul></dd>







</dl>















<h5>Returns:</h5>


<div class="param-desc">
The product of the multiplication.
</div>



<dl>
<dt>
Type
</dt>
<dd>

<span class="param-type">this</span>


</dd>
</dl>











Expand All @@ -385,7 +547,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Complex.h
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 06 2023 10:28:46 GMT-0300 (GMT-03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Sep 07 2023 13:07:52 GMT-0300 (GMT-03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
16 changes: 15 additions & 1 deletion docs/jsdoc/complex.mjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h1 class="page-title">Source: complex.mjs</h1>

/**
* An immutable complex number class with real and imaginary parts.
* @name Complex
* @class Complex
*/
export default class Complex {
Expand Down Expand Up @@ -1046,6 +1047,7 @@ <h1 class="page-title">Source: complex.mjs</h1>
* @memberof Complex
* @instance
* @return {number} The absolute length value of this complex number.
* @description Alias of Complex::abs().
*/
Complex.prototype.mod = Complex.prototype.abs;

Expand All @@ -1055,9 +1057,21 @@ <h1 class="page-title">Source: complex.mjs</h1>
* @memberof Complex
* @instance
* @return {number} The squared absolute value of this complex number.
* @description Alias of Complex::abs_squared().
*/
Complex.prototype.modSq = Complex.prototype.abs_squared;

/**
* Multiplies this complex number by another complex number or a scalar.
* @method mul
* @memberof Complex
* @instance
* @param {(Cobj | number)} n The multiplicand.
* @return {this} The product of the multiplication.
* @description Alias of Complex::mult().
*/
Complex.prototype.mul = Complex.prototype.mult;

// Freeze the Complex class to prevent further modifications to
// its static properties &amp; methods:
Object.freeze(Complex);
Expand All @@ -1077,7 +1091,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Complex.h
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Sep 06 2023 10:28:46 GMT-0300 (GMT-03:00)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Sep 07 2023 13:07:52 GMT-0300 (GMT-03:00)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit 22d0734

Please sign in to comment.