js-array-ext
Version:
JavaScript Array Extension
2,254 lines (605 loc) • 26.2 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="combine"><span class="type-signature"></span>combine<span class="signature">(arr1, arr2, processFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Call to processFunction wich each possible combination of elements in arr1 and arr2
and return an array with the result of each call to processFunction. ej. We have two list of coords and
we want all possible combinations of points. Simple as call this functions with the list and the constructor.
</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>arr1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">Unsorted array.</td>
</tr>
<tr>
<td class="name"><code>arr2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">Unsorted array.</td>
</tr>
<tr>
<td class="name"><code>processFunction</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">Two arguments function which return a new element.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line19">line 19</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="compare"><span class="type-signature"></span>compare<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"> → {Number}</span></h4>
<div class="description">
Compared each two elements in two sorted arrays until one return non sero value.
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line104">line 104</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
A number minor, equal or bigger than 0 according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
<h4 class="name" id="equal"><span class="type-signature"></span>equal<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"> → {Bool}</span></h4>
<div class="description">
Compare two sorted array
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line82">line 82</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Return true if succeed or false other way.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Bool</span>
</dd>
</dl>
<h4 class="name" id="exclusion"><span class="type-signature"></span>exclusion<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"></span></h4>
<div class="description">
New SortFilter Array with elements of srtf1 which are not duplicated in srtf2.
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line171">line 171</a>
</li></ul></dd>
</dl>
<h4 class="name" id="intersection"><span class="type-signature"></span>intersection<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
New SortFilter Array with elements duplicated in both Arrays, by duplicate means compare function return 0.
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line150">line 150</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="mutualExclusion"><span class="type-signature"></span>mutualExclusion<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"></span></h4>
<div class="description">
New SortFilter Array with elements of srtf1 which are not duplicated in srtf2
and elements of srtf2 which are not duplicated in srtf1.
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line181">line 181</a>
</li></ul></dd>
</dl>
<h4 class="name" id="removeEquals"><span class="type-signature"></span>removeEquals<span class="signature">(srtf, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Compare contiguous elemented and remove the second if the compare function return any
value different than 0.
This method is usual used to remove repeated elements in a previously sorted Array.
</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>srtf</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line47">line 47</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="sliceFind"><span class="type-signature"></span>sliceFind<span class="signature">(srtf, value, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
New Array starting from first index where compare function return 0 or positive numeber.
</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>srtf</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">, SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line125">line 125</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="sort"><span class="type-signature"></span>sort<span class="signature">(array, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Same as Array.sort with the addition that is retuning a new Array.
</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>array</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line28">line 28</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="sortFilter"><span class="type-signature"></span>sortFilter<span class="signature">(array, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Sort Array and then remove equal contiguos elements in both cases using compare function.
</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>array</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line55">line 55</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
<h4 class="name" id="union"><span class="type-signature"></span>union<span class="signature">(srtf1, srtf2, compareFunction)</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
SortFilter Array of values in both sorted arrays without repeating values.
</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>srtf1</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>srtf2</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="description last">SortFilter Array.</td>
</tr>
<tr>
<td class="name"><code>compareFunction</code></td>
<td class="type">
<span class="param-type">Funcion</span>
</td>
<td class="description last">Two argument function that return a number minor, equal or bigger than 0.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line115">line 115</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
New Array of elements according to description.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#combine">combine</a></li><li><a href="global.html#compare">compare</a></li><li><a href="global.html#equal">equal</a></li><li><a href="global.html#exclusion">exclusion</a></li><li><a href="global.html#intersection">intersection</a></li><li><a href="global.html#mutualExclusion">mutualExclusion</a></li><li><a href="global.html#removeEquals">removeEquals</a></li><li><a href="global.html#sliceFind">sliceFind</a></li><li><a href="global.html#sort">sort</a></li><li><a href="global.html#sortFilter">sortFilter</a></li><li><a href="global.html#union">union</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.4</a> on Mon Aug 14 2017 16:21:40 GMT-0700 (PDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>