Travis build: 711

This commit is contained in:
30secondsofcode
2018-10-31 16:51:58 +00:00
parent d998d1a7f9
commit 0e58603310
10 changed files with 39 additions and 40 deletions

View File

@ -2374,7 +2374,7 @@ sampleSize([1, 2, 3], 4); // [2,3,1]
### shank
Has the same functionality as [`Array.prototype.prototype.splice()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice), but returning a new array instead of mutating the original array.
Has the same functionality as [`Array.prototype.splice()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice), but returning a new array instead of mutating the original array.
Use `Array.prototype.slice()` and `Array.prototype.concat()` to get a new array with the new contents after removing existing elements and/or adding new elements.
Omit the second argument, `index`, to start at `0`.
@ -2399,7 +2399,6 @@ const namesNoBravo = shank(names, 1, 1); // [ 'alpha', 'charlie' ]
console.log(names); // ['alpha', 'bravo', 'charlie']
```
</details>
<br>[⬆ Back to top](#table-of-contents)
@ -2790,7 +2789,7 @@ takeWhile([1, 2, 3, 4], n => n >= 3); // [1, 2]
Reduces a given Array-like into a value hash (keyed data store).
Given an Iterable or Array-like structure, call `Array.prototype.prototype.reduce.call()` on the provided object to step over it and return an Object, keyed by the reference value.
Given an Iterable or Array-like structure, call `Array.prototype.reduce.call()` on the provided object to step over it and return an Object, keyed by the reference value.
```js
const toHash = (object, key) =>

View File

@ -423,7 +423,7 @@
};</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">sampleSize</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">2</span><span class="token punctuation">);</span> <span class="token comment">// [3,1]</span>
<span class="token function">sampleSize</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">// [2,3,1]</span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="shank">shank</h4><p>Has the same functionality as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice"><code>Array.prototype.prototype.splice()</code></a>, but returning a new array instead of mutating the original array.</p><p>Use <code>Array.prototype.slice()</code> and <code>Array.prototype.concat()</code> to get a new array with the new contents after removing existing elements and/or adding new elements. Omit the second argument, <code>index</code>, to start at <code>0</code>. Omit the third argument, <code>delCount</code>, to remove <code>0</code> elements. Omit the fourth argument, <code>elements</code>, in order to not add any new elements.</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">shank</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> delCount <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">...</span>elements<span class="token punctuation">)</span> <span class="token operator">=></span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="shank">shank</h4><p>Has the same functionality as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice"><code>Array.prototype.splice()</code></a>, but returning a new array instead of mutating the original array.</p><p>Use <code>Array.prototype.slice()</code> and <code>Array.prototype.concat()</code> to get a new array with the new contents after removing existing elements and/or adding new elements. Omit the second argument, <code>index</code>, to start at <code>0</code>. Omit the third argument, <code>delCount</code>, to remove <code>0</code> elements. Omit the fourth argument, <code>elements</code>, in order to not add any new elements.</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">shank</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> delCount <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token operator">...</span>elements<span class="token punctuation">)</span> <span class="token operator">=></span>
arr
<span class="token punctuation">.</span><span class="token function">slice</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> index<span class="token punctuation">)
.</span><span class="token function">concat</span><span class="token punctuation">(</span>elements<span class="token punctuation">)
@ -520,7 +520,7 @@ console<span class="token punctuation">.</span><span class="token function">log<
<span class="token keyword">return</span> arr<span class="token punctuation">;
};</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">takeWhile</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> n <span class="token operator">=></span> n <span class="token operator">>=</span> <span class="token number">3</span><span class="token punctuation">);</span> <span class="token comment">// [1, 2]</span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="tohash">toHash</h4><p>Reduces a given Array-like into a value hash (keyed data store).</p><p>Given an Iterable or Array-like structure, call <code>Array.prototype.prototype.reduce.call()</code> on the provided object to step over it and return an Object, keyed by the reference value.</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">toHash</span> <span class="token operator">=</span> <span class="token punctuation">(</span>object<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token operator">=></span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="tohash">toHash</h4><p>Reduces a given Array-like into a value hash (keyed data store).</p><p>Given an Iterable or Array-like structure, call <code>Array.prototype.reduce.call()</code> on the provided object to step over it and return an Object, keyed by the reference value.</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">toHash</span> <span class="token operator">=</span> <span class="token punctuation">(</span>object<span class="token punctuation">,</span> key<span class="token punctuation">)</span> <span class="token operator">=></span>
Array<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>reduce<span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span>
object<span class="token punctuation">,
(</span>acc<span class="token punctuation">,</span> data<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">((</span>acc<span class="token punctuation">[</span><span class="token operator">!</span>key <span class="token operator">?</span> index <span class="token punctuation">:</span> data<span class="token punctuation">[</span>key<span class="token punctuation">]]</span> <span class="token operator">=</span> data<span class="token punctuation">),</span> acc<span class="token punctuation">),