Travis build: 996
This commit is contained in:
@ -668,13 +668,14 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
|
||||
const sum = pipeAsyncFunctions(
|
||||
x => x + 1,
|
||||
x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
|
||||
x => x + 3,
|
||||
async x => (await x) + 4
|
||||
);
|
||||
(async () => {
|
||||
(async() => {
|
||||
console.log(await sum(5)); // 15 (after one second)
|
||||
})();
|
||||
```
|
||||
@ -2316,6 +2317,7 @@ Use `Array.prototype.filter()` to find array elements that return truthy values
|
||||
The `func` is invoked with three arguments (`value, index, array`).
|
||||
|
||||
```js
|
||||
|
||||
const remove = (arr, func) =>
|
||||
Array.isArray(arr)
|
||||
? arr.filter(func).reduce((acc, val) => {
|
||||
@ -5499,6 +5501,7 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
|
||||
Throws an exception if `n` is a negative number.
|
||||
|
||||
```js
|
||||
|
||||
const factorial = n =>
|
||||
n < 0
|
||||
? (() => {
|
||||
@ -6753,6 +6756,7 @@ Use `Object.keys(obj)` to iterate over the object's keys.
|
||||
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
|
||||
|
||||
```js
|
||||
|
||||
const deepMapKeys = (obj, f) =>
|
||||
Array.isArray(obj)
|
||||
? obj.map(val => deepMapKeys(val, f))
|
||||
@ -6832,6 +6836,7 @@ Use the `in` operator to check if `target` exists in `obj`.
|
||||
If found, return the value of `obj[target]`, otherwise use `Object.values(obj)` and `Array.prototype.reduce()` to recursively call `dig` on each nested object until the first matching key/value pair is found.
|
||||
|
||||
```js
|
||||
|
||||
const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
|
||||
@ -127,13 +127,14 @@ Object<span class="token punctuation">.</span><span class="token function">assig
|
||||
<span class="token keyword">const</span> fn <span class="token operator">=</span> <span class="token function">overArgs</span><span class="token punctuation">((</span>x<span class="token punctuation">,</span> y<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">[</span>x<span class="token punctuation">,</span> y<span class="token punctuation">], [</span>square<span class="token punctuation">,</span> double<span class="token punctuation">]);</span>
|
||||
<span class="token function">fn</span><span class="token punctuation">(</span><span class="token number">9</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">);</span> <span class="token comment">// [81, 6]</span>
|
||||
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="pipeasyncfunctions">pipeAsyncFunctions</h4><p>Performs left-to-right function composition for asynchronous functions.</p><p>Use <code>Array.prototype.reduce()</code> with the spread operator (<code>...</code>) to perform left-to-right function composition using <code>Promise.then()</code>. The functions can return a combination of: simple values, <code>Promise</code>'s, or they can be defined as <code>async</code> ones returning through <code>await</code>. All functions must be unary.</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">pipeAsyncFunctions</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token operator">...</span>fns<span class="token punctuation">)</span> <span class="token operator">=></span> arg <span class="token operator">=></span> fns<span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">((</span>p<span class="token punctuation">,</span> f<span class="token punctuation">)</span> <span class="token operator">=></span> p<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span>f<span class="token punctuation">),</span> Promise<span class="token punctuation">.</span><span class="token function">resolve</span><span class="token punctuation">(</span>arg<span class="token punctuation">));</span>
|
||||
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token keyword">const</span> sum <span class="token operator">=</span> <span class="token function">pipeAsyncFunctions</span><span class="token punctuation">(</span>
|
||||
</pre><label class="collapse">examples</label><pre class="section card-examples language-js">
|
||||
<span class="token keyword">const</span> sum <span class="token operator">=</span> <span class="token function">pipeAsyncFunctions</span><span class="token punctuation">(</span>
|
||||
x <span class="token operator">=></span> x <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">,</span>
|
||||
x <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span>resolve <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(()</span> <span class="token operator">=></span> <span class="token function">resolve</span><span class="token punctuation">(</span>x <span class="token operator">+</span> <span class="token number">2</span><span class="token punctuation">),</span> <span class="token number">1000</span><span class="token punctuation">)),</span>
|
||||
x <span class="token operator">=></span> x <span class="token operator">+</span> <span class="token number">3</span><span class="token punctuation">,</span>
|
||||
<span class="token keyword">async</span> x <span class="token operator">=></span> <span class="token punctuation">(</span><span class="token keyword">await</span> x<span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">4</span>
|
||||
<span class="token punctuation">);
|
||||
(</span><span class="token keyword">async</span> <span class="token punctuation">()</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
(</span><span class="token keyword">async</span><span class="token punctuation">()</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">await</span> <span class="token function">sum</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">));</span> <span class="token comment">// 15 (after one second)</span>
|
||||
<span class="token punctuation">})();</span>
|
||||
</pre></div><div class="card code-card"><div class="section card-content"><h4><a href="https://frontendmasters.com/courses/es6-right-parts/" target="_blank" rel="noopener noreferrer">Recommended Resource - ES6: The Right Parts</a></h4><p>Learn new ES6 JavaScript language features like arrow function, destructuring, generators & more to write cleaner and more productive, readable programs.</p></div></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="pipefunctions">pipeFunctions</h4><p>Performs left-to-right function composition.</p><p>Use <code>Array.prototype.reduce()</code> with the spread operator (<code>...</code>) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.</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">pipeFunctions</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token operator">...</span>fns<span class="token punctuation">)</span> <span class="token operator">=></span> fns<span class="token punctuation">.</span><span class="token function">reduce</span><span class="token punctuation">((</span>f<span class="token punctuation">,</span> g<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span><span class="token operator">...</span>args<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token function">g</span><span class="token punctuation">(</span><span class="token function">f</span><span class="token punctuation">(</span><span class="token operator">...</span>args<span class="token punctuation">)));</span>
|
||||
|
||||
@ -407,7 +407,8 @@
|
||||
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="reject">reject</h4><p>Takes a predicate and array, like <code>Array.prototype.filter()</code>, but only keeps <code>x</code> if <code>pred(x) === false</code>.</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">reject</span> <span class="token operator">=</span> <span class="token punctuation">(</span>pred<span class="token punctuation">,</span> array<span class="token punctuation">)</span> <span class="token operator">=></span> array<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">((</span><span class="token operator">...</span>args<span class="token punctuation">)</span> <span class="token operator">=> !</span><span class="token function">pred</span><span class="token punctuation">(</span><span class="token operator">...</span>args<span class="token punctuation">));</span>
|
||||
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">reject</span><span class="token punctuation">(</span>x <span class="token operator">=></span> x <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">===</span> <span class="token number">0</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 number">5</span><span class="token punctuation">]);</span> <span class="token comment">// [1, 3, 5]</span>
|
||||
<span class="token function">reject</span><span class="token punctuation">(</span>word <span class="token operator">=></span> word<span class="token punctuation">.</span>length <span class="token operator">></span> <span class="token number">4</span><span class="token punctuation">, [</span><span class="token string">'Apple'</span><span class="token punctuation">,</span> <span class="token string">'Pear'</span><span class="token punctuation">,</span> <span class="token string">'Kiwi'</span><span class="token punctuation">,</span> <span class="token string">'Banana'</span><span class="token punctuation">]);</span> <span class="token comment">// ['Pear', 'Kiwi']</span>
|
||||
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="remove">remove</h4><p>Removes elements from an array for which the given function returns <code>false</code>.</p><p>Use <code>Array.prototype.filter()</code> to find array elements that return truthy values and <code>Array.prototype.reduce()</code> to remove elements using <code>Array.prototype.splice()</code>. The <code>func</code> is invoked with three arguments (<code>value, index, array</code>).</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">remove</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> func<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="remove">remove</h4><p>Removes elements from an array for which the given function returns <code>false</code>.</p><p>Use <code>Array.prototype.filter()</code> to find array elements that return truthy values and <code>Array.prototype.reduce()</code> to remove elements using <code>Array.prototype.splice()</code>. The <code>func</code> is invoked with three arguments (<code>value, index, array</code>).</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">remove</span> <span class="token operator">=</span> <span class="token punctuation">(</span>arr<span class="token punctuation">,</span> func<span class="token punctuation">)</span> <span class="token operator">=></span>
|
||||
Array<span class="token punctuation">.</span><span class="token function">isArray</span><span class="token punctuation">(</span>arr<span class="token punctuation">)</span>
|
||||
<span class="token operator">?</span> arr<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span>func<span class="token punctuation">).</span><span class="token function">reduce</span><span class="token punctuation">((</span>acc<span class="token punctuation">,</span> val<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
arr<span class="token punctuation">.</span><span class="token function">splice</span><span class="token punctuation">(</span>arr<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span>val<span class="token punctuation">),</span> <span class="token number">1</span><span class="token punctuation">);</span>
|
||||
|
||||
@ -149,7 +149,8 @@ For teams, each rating can adjusted based on own team's average rating vs.
|
||||
average rating of opposing team, with the score being added to their
|
||||
own individual rating by supplying it as the third argument.
|
||||
*/</span>
|
||||
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="factorial">factorial</h4><p>Calculates the factorial of a number.</p><p>Use recursion. If <code>n</code> is less than or equal to <code>1</code>, return <code>1</code>. Otherwise, return the product of <code>n</code> and the factorial of <code>n - 1</code>. Throws an exception if <code>n</code> is a negative number.</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">factorial</span> <span class="token operator">=</span> n <span class="token operator">=></span>
|
||||
</pre></div><div class="card code-card"><div class="corner beginner"></div><div class="section card-content"><h4 id="factorial">factorial</h4><p>Calculates the factorial of a number.</p><p>Use recursion. If <code>n</code> is less than or equal to <code>1</code>, return <code>1</code>. Otherwise, return the product of <code>n</code> and the factorial of <code>n - 1</code>. Throws an exception if <code>n</code> is a negative number.</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">factorial</span> <span class="token operator">=</span> n <span class="token operator">=></span>
|
||||
n <span class="token operator"><</span> <span class="token number">0</span>
|
||||
<span class="token operator">?</span> <span class="token punctuation">(()</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">throw new</span> <span class="token class-name">TypeError</span><span class="token punctuation">(</span><span class="token string">'Negative numbers are not allowed!'</span><span class="token punctuation">);
|
||||
|
||||
@ -134,7 +134,8 @@
|
||||
|
||||
o<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">;</span> <span class="token comment">// not allowed</span>
|
||||
o<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">][</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">;</span> <span class="token comment">// not allowed as well</span>
|
||||
</pre></div><div class="card code-card"><div class="corner advanced"></div><div class="section card-content"><h4 id="deepmapkeys">deepMapKeys</h4><p>Deep maps an object keys.</p><p>Creates an object with the same values as the provided object and keys generated by running the provided function for each key.</p><p>Use <code>Object.keys(obj)</code> to iterate over the object's keys. Use <code>Array.prototype.reduce()</code> to create a new object with the same values and mapped keys using <code>fn</code>.</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">deepMapKeys</span> <span class="token operator">=</span> <span class="token punctuation">(</span>obj<span class="token punctuation">,</span> f<span class="token punctuation">)</span> <span class="token operator">=></span>
|
||||
</pre></div><div class="card code-card"><div class="corner advanced"></div><div class="section card-content"><h4 id="deepmapkeys">deepMapKeys</h4><p>Deep maps an object keys.</p><p>Creates an object with the same values as the provided object and keys generated by running the provided function for each key.</p><p>Use <code>Object.keys(obj)</code> to iterate over the object's keys. Use <code>Array.prototype.reduce()</code> to create a new object with the same values and mapped keys using <code>fn</code>.</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">deepMapKeys</span> <span class="token operator">=</span> <span class="token punctuation">(</span>obj<span class="token punctuation">,</span> f<span class="token punctuation">)</span> <span class="token operator">=></span>
|
||||
Array<span class="token punctuation">.</span><span class="token function">isArray</span><span class="token punctuation">(</span>obj<span class="token punctuation">)</span>
|
||||
<span class="token operator">?</span> obj<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>val <span class="token operator">=></span> <span class="token function">deepMapKeys</span><span class="token punctuation">(</span>val<span class="token punctuation">,</span> f<span class="token punctuation">))
|
||||
:</span> <span class="token keyword">typeof</span> obj <span class="token operator">===</span> <span class="token string">'object'</span>
|
||||
@ -174,7 +175,8 @@ o<span class="token punctuation">[</span><span class="token number">1</span><spa
|
||||
*/</span>
|
||||
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="defaults">defaults</h4><p>Assigns default values for all properties in an object that are <code>undefined</code>.</p><p>Use <code>Object.assign()</code> to create a new empty object and copy the original one to maintain key order, use <code>Array.prototype.reverse()</code> and the spread operator <code>...</code> to combine the default values from left to right, finally use <code>obj</code> again to overwrite properties that originally had a 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">defaults</span> <span class="token operator">=</span> <span class="token punctuation">(</span>obj<span class="token punctuation">,</span> <span class="token operator">...</span>defs<span class="token punctuation">)</span> <span class="token operator">=></span> Object<span class="token punctuation">.</span><span class="token function">assign</span><span class="token punctuation">({},</span> obj<span class="token punctuation">,</span> <span class="token operator">...</span>defs<span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(),</span> obj<span class="token punctuation">);</span>
|
||||
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">defaults</span><span class="token punctuation">({</span> a<span class="token punctuation">:</span> <span class="token number">1</span> <span class="token punctuation">}, {</span> b<span class="token punctuation">:</span> <span class="token number">2</span> <span class="token punctuation">}, {</span> b<span class="token punctuation">:</span> <span class="token number">6</span> <span class="token punctuation">}, {</span> a<span class="token punctuation">:</span> <span class="token number">3</span> <span class="token punctuation">});</span> <span class="token comment">// { a: 1, b: 2 }</span>
|
||||
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="dig">dig</h4><p>Returns the target value in a nested JSON object, based on the given key.</p><p>Use the <code>in</code> operator to check if <code>target</code> exists in <code>obj</code>. If found, return the value of <code>obj[target]</code>, otherwise use <code>Object.values(obj)</code> and <code>Array.prototype.reduce()</code> to recursively call <code>dig</code> on each nested object until the first matching key/value pair is found.</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">dig</span> <span class="token operator">=</span> <span class="token punctuation">(</span>obj<span class="token punctuation">,</span> target<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="dig">dig</h4><p>Returns the target value in a nested JSON object, based on the given key.</p><p>Use the <code>in</code> operator to check if <code>target</code> exists in <code>obj</code>. If found, return the value of <code>obj[target]</code>, otherwise use <code>Object.values(obj)</code> and <code>Array.prototype.reduce()</code> to recursively call <code>dig</code> on each nested object until the first matching key/value pair is found.</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">dig</span> <span class="token operator">=</span> <span class="token punctuation">(</span>obj<span class="token punctuation">,</span> target<span class="token punctuation">)</span> <span class="token operator">=></span>
|
||||
target <span class="token keyword">in</span> obj
|
||||
<span class="token operator">?</span> obj<span class="token punctuation">[</span>target<span class="token punctuation">]
|
||||
:</span> Object<span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span>obj<span class="token punctuation">).</span><span class="token function">reduce</span><span class="token punctuation">((</span>acc<span class="token punctuation">,</span> val<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
|
||||
@ -8,6 +8,7 @@ Use `Object.keys(obj)` to iterate over the object's keys.
|
||||
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
|
||||
|
||||
```js
|
||||
|
||||
const deepMapKeys = (obj, f) =>
|
||||
Array.isArray(obj)
|
||||
? obj.map(val => deepMapKeys(val, f))
|
||||
|
||||
@ -6,6 +6,7 @@ Use the `in` operator to check if `target` exists in `obj`.
|
||||
If found, return the value of `obj[target]`, otherwise use `Object.values(obj)` and `Array.prototype.reduce()` to recursively call `dig` on each nested object until the first matching key/value pair is found.
|
||||
|
||||
```js
|
||||
|
||||
const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
|
||||
@ -8,6 +8,7 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
|
||||
Throws an exception if `n` is a negative number.
|
||||
|
||||
```js
|
||||
|
||||
const factorial = n =>
|
||||
n < 0
|
||||
? (() => {
|
||||
|
||||
@ -11,13 +11,14 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
const sum = pipeAsyncFunctions(
|
||||
x => x + 1,
|
||||
x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
|
||||
x => x + 3,
|
||||
async x => (await x) + 4
|
||||
);
|
||||
(async () => {
|
||||
(async() => {
|
||||
console.log(await sum(5)); // 15 (after one second)
|
||||
})();
|
||||
```
|
||||
|
||||
@ -6,6 +6,7 @@ Use `Array.prototype.filter()` to find array elements that return truthy values
|
||||
The `func` is invoked with three arguments (`value, index, array`).
|
||||
|
||||
```js
|
||||
|
||||
const remove = (arr, func) =>
|
||||
Array.isArray(arr)
|
||||
? arr.filter(func).reduce((acc, val) => {
|
||||
|
||||
@ -235,6 +235,7 @@ const deepFreeze = obj =>
|
||||
prop =>
|
||||
!(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
|
||||
) || Object.freeze(obj);
|
||||
|
||||
const deepMapKeys = (obj, f) =>
|
||||
Array.isArray(obj)
|
||||
? obj.map(val => deepMapKeys(val, f))
|
||||
@ -263,6 +264,7 @@ const differenceBy = (a, b, fn) => {
|
||||
return a.filter(x => !s.has(fn(x)));
|
||||
};
|
||||
const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
|
||||
|
||||
const dig = (obj, target) =>
|
||||
target in obj
|
||||
? obj[target]
|
||||
@ -338,6 +340,7 @@ const extendHex = shortHex =>
|
||||
.split('')
|
||||
.map(x => x + x)
|
||||
.join('');
|
||||
|
||||
const factorial = n =>
|
||||
n < 0
|
||||
? (() => {
|
||||
@ -985,6 +988,7 @@ const reducedFilter = (data, keys, fn) =>
|
||||
}, {})
|
||||
);
|
||||
const reject = (pred, array) => array.filter((...args) => !pred(...args));
|
||||
|
||||
const remove = (arr, func) =>
|
||||
Array.isArray(arr)
|
||||
? arr.filter(func).reduce((acc, val) => {
|
||||
|
||||
Reference in New Issue
Block a user