Travis build: 891

This commit is contained in:
30secondsofcode
2018-12-12 17:17:27 +00:00
parent b1f985e026
commit b25e9f87a0
11 changed files with 18 additions and 30 deletions

View File

@ -5490,7 +5490,6 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
Throws an exception if `n` is a negative number. Throws an exception if `n` is a negative number.
```js ```js
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {
@ -6719,7 +6718,6 @@ 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`. Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
```js ```js
const deepMapKeys = (obj, f) => const deepMapKeys = (obj, f) =>
Array.isArray(obj) Array.isArray(obj)
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))
@ -6799,7 +6797,6 @@ 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. 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 ```js
const dig = (obj, target) => const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]

View File

@ -147,8 +147,7 @@ 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 average rating of opposing team, with the score being added to their
own individual rating by supplying it as the third argument. own individual rating by supplying it as the third argument.
*/</span> */</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"> </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>
<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">&lt;</span> <span class="token number">0</span> n <span class="token operator">&lt;</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 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">); <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">);

View File

@ -128,8 +128,7 @@
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">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> 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"> </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>
<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> 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 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> :</span> <span class="token keyword">typeof</span> obj <span class="token operator">===</span> <span class="token string">'object'</span>
@ -169,8 +168,7 @@ o<span class="token punctuation">[</span><span class="token number">1</span><spa
*/</span> */</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></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><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"> </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>
<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 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 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> :</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>

View File

@ -8,7 +8,6 @@ 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`. Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.
```js ```js
const deepMapKeys = (obj, f) => const deepMapKeys = (obj, f) =>
Array.isArray(obj) Array.isArray(obj)
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))

View File

@ -6,7 +6,6 @@ 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. 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 ```js
const dig = (obj, target) => const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]

View File

@ -8,7 +8,6 @@ Otherwise, return the product of `n` and the factorial of `n - 1`.
Throws an exception if `n` is a negative number. Throws an exception if `n` is a negative number.
```js ```js
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {

View File

@ -224,7 +224,6 @@ const deepFreeze = obj =>
prop => prop =>
!(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
) || Object.freeze(obj); ) || Object.freeze(obj);
const deepMapKeys = (obj, f) => const deepMapKeys = (obj, f) =>
Array.isArray(obj) Array.isArray(obj)
? obj.map(val => deepMapKeys(val, f)) ? obj.map(val => deepMapKeys(val, f))
@ -253,7 +252,6 @@ const differenceBy = (a, b, fn) => {
return a.filter(x => !s.has(fn(x))); return a.filter(x => !s.has(fn(x)));
}; };
const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);
const dig = (obj, target) => const dig = (obj, target) =>
target in obj target in obj
? obj[target] ? obj[target]
@ -329,7 +327,6 @@ const extendHex = shortHex =>
.split('') .split('')
.map(x => x + x) .map(x => x + x)
.join(''); .join('');
const factorial = n => const factorial = n =>
n < 0 n < 0
? (() => { ? (() => {