Travis build: 1221

This commit is contained in:
30secondsofcode
2019-06-07 15:03:12 +00:00
parent 11b6b82fc8
commit 16ade9e840
13 changed files with 57 additions and 54 deletions

View File

@ -2976,9 +2976,9 @@ uniqueElementsBy(
### uniqueElementsByRight
Returns all unique values of an array, based on a provided comparator function.
Returns all unique values of an array, based on a provided comparator function, starting from the right.
Use `Array.prototype.reduce()` and `Array.prototype.some()` for an array containing only the last unique occurrence of each value, based on the comparator function, `fn`.
Use `Array.prototype.reduceRight()` and `Array.prototype.some()` for an array containing only the last unique occurrence of each value, based on the comparator function, `fn`.
The comparator function takes two arguments: the values of the two elements being compared.
```js
@ -4745,6 +4745,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false

View File

@ -164,6 +164,7 @@ console<span class="token punctuation">.</span><span class="token function">log<
<span class="token keyword">const</span> lengthIs4 <span class="token operator">=</span> <span class="token function">checkProp</span><span class="token punctuation">(</span>l <span class="token operator">=></span> l <span class="token operator">===</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">);</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([]);</span> <span class="token comment">// false</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]);</span> <span class="token comment">// true</span>

View File

@ -574,7 +574,7 @@ managers<span class="token punctuation">;</span> <span class="token comment">//
],
(</span>a<span class="token punctuation">,</span> b<span class="token punctuation">)</span> <span class="token operator">=></span> a<span class="token punctuation">.</span>id <span class="token operator">==</span> b<span class="token punctuation">.</span>id
<span class="token punctuation">);</span> <span class="token comment">// [ { id: 0, value: 'a' }, { id: 1, value: 'b' }, { id: 2, value: 'c' } ]</span>
</pre></div><div class="card code-card"><div class="corner intermediate" aria-label="intermediate" title="intermediate"></div><div class="section card-content"><h4 id="uniqueelementsbyright">uniqueElementsByRight</h4><p>Returns all unique values of an array, based on a provided comparator function.</p><p>Use <code>Array.prototype.reduce()</code> and <code>Array.prototype.some()</code> for an array containing only the last unique occurrence of each value, based on the comparator function, <code>fn</code>. The comparator function takes two arguments: the values of the two elements being compared.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">uniqueElementsByRight</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> fn<span class="token punctuation">)</span> <span class="token operator">=></span>
</pre></div><div class="card code-card"><div class="corner intermediate" aria-label="intermediate" title="intermediate"></div><div class="section card-content"><h4 id="uniqueelementsbyright">uniqueElementsByRight</h4><p>Returns all unique values of an array, based on a provided comparator function, starting from the right.</p><p>Use <code>Array.prototype.reduceRight()</code> and <code>Array.prototype.some()</code> for an array containing only the last unique occurrence of each value, based on the comparator function, <code>fn</code>. The comparator function takes two arguments: the values of the two elements being compared.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">uniqueElementsByRight</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> fn<span class="token punctuation">)</span> <span class="token operator">=></span>
arr<span class="token punctuation">.</span><span class="token function">reduceRight</span><span class="token punctuation">((</span>acc<span class="token punctuation">,</span> v<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>acc<span class="token punctuation">.</span><span class="token function">some</span><span class="token punctuation">(</span>x <span class="token operator">=></span> <span class="token function">fn</span><span class="token punctuation">(</span>v<span class="token punctuation">,</span> x<span class="token punctuation">)))</span> acc<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>v<span class="token punctuation">);</span>
<span class="token keyword">return</span> acc<span class="token punctuation">;

View File

@ -28,6 +28,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false