Travis build: 16

This commit is contained in:
30secondsofcode
2018-06-23 13:39:46 +00:00
parent 35aee0ae9c
commit f8bf7bc50d
2 changed files with 38 additions and 38 deletions

View File

@ -503,16 +503,16 @@ const firstTwoMax = ary(Math.max, 2);
<br>[⬆ Back to top](#table-of-contents)
### call
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
Use a closure to call a stored key with stored arguments.
### call
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
Use a closure to call a stored key with stored arguments.
```js
const call = (key, ...args) => context => context[key](...args);
```
```
<details>
<summary>Examples</summary>
@ -524,23 +524,23 @@ const map = call.bind(null, 'map');
Promise.resolve([1, 2, 3])
.then(map(x => 2 * x))
.then(console.log); //[ 2, 4, 6 ]
```
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### collectInto
Changes a function that accepts an array into a variadic function.
Given a function, return a closure that collects all inputs into an array-accepting function.
### collectInto
Changes a function that accepts an array into a variadic function.
Given a function, return a closure that collects all inputs into an array-accepting function.
```js
const collectInto = fn => (...args) => fn(args);
```
```
<details>
<summary>Examples</summary>
@ -550,23 +550,23 @@ let p1 = Promise.resolve(1);
let p2 = Promise.resolve(2);
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
```
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### flip
Flip takes a function as an argument, then makes the first argument the last.
Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
### flip
Flip takes a function as an argument, then makes the first argument the last.
Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
```js
const flip = fn => (first, ...rest) => fn(...rest, first);
```
```
<details>
<summary>Examples</summary>
@ -578,7 +578,7 @@ let mergePerson = mergeFrom.bind(null, a);
mergePerson(b); // == b
b = {};
Object.assign(b, a); // == b
```
```
</details>
@ -754,23 +754,23 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c']
<br>[⬆ Back to top](#table-of-contents)
### spreadOver
Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
### spreadOver
Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
```js
const spreadOver = fn => argsArr => fn(...argsArr);
```
```
<details>
<summary>Examples</summary>
```js
const arrayMax = spreadOver(Math.max);
arrayMax([1, 2, 3]); // 3
```
```
</details>
@ -6694,7 +6694,7 @@ const matchesWith = (obj, source, fn) =>
key =>
obj.hasOwnProperty(key) && fn
? fn(obj[key], source[key], key, obj, source)
: obj[key] === source[key]
: obj[key] == source[key]
);
```

View File

@ -327,7 +327,7 @@ Foo<span class="token punctuation">.</span>prototype<span class="token punctuati
);</span> <span class="token comment">// { '1': ['a', 'c'], '2': ['b'] }</span>
</pre><button class="primary clipboard-copy">&#128203;&nbsp;Copy to clipboard</button></div></div><div class="card fluid"><h3 id="truthcheckcollection" class="section double-padded">truthCheckCollection</h3><div class="section double-padded"><p>Checks if the predicate (second argument) is truthy on all elements of a collection (first argument).</p><p>Use <code>Array.every()</code> to check if each passed object has the specified property and if it returns a truthy value.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">truthCheckCollection</span> <span class="token operator">=</span> <span class="token punctuation">(</span>collection<span class="token punctuation">,</span> pre<span class="token punctuation">)</span> <span class="token operator">=></span> collection<span class="token punctuation">.</span><span class="token function">every</span><span class="token punctuation">(</span>obj <span class="token operator">=></span> obj<span class="token punctuation">[</span>pre<span class="token punctuation">]);</span>
</pre><label class="collapse">Show examples</label><pre class="language-js"><span class="token function">truthCheckCollection</span><span class="token punctuation">([{</span> user<span class="token punctuation">:</span> <span class="token string">'Tinky-Winky'</span><span class="token punctuation">,</span> sex<span class="token punctuation">:</span> <span class="token string">'male'</span> <span class="token punctuation">}, {</span> user<span class="token punctuation">:</span> <span class="token string">'Dipsy'</span><span class="token punctuation">,</span> sex<span class="token punctuation">:</span> <span class="token string">'male'</span> <span class="token punctuation">}],</span> <span class="token string">'sex'</span><span class="token punctuation">);</span> <span class="token comment">// true</span>
</pre><button class="primary clipboard-copy">&#128203;&nbsp;Copy to clipboard</button></div></div><div class="card fluid"><h3 id="unflattenobject" class="section double-padded">unflattenObject<mark class="tag">advanced</mark></h3><div class="section double-padded"><p>Unlatten an object with the paths for keys.</p><p>Use <code>Object.keys(obj)</code> combined with <code>Array.reduce()</code> to convert flattened path node to a leaf node. If the value of a key contains a dot delimiter (<code>.</code>), use <code>Array.split('.')</code>, string transformations and <code>JSON.parse()</code> to create an object, then <code>Object.assign()</code> to create the leaf node. Otherwise, add the appropriate key-value pair to the accumulator object.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">unflattenObject</span> <span class="token operator">=</span> obj <span class="token operator">=></span>
</pre><button class="primary clipboard-copy">&#128203;&nbsp;Copy to clipboard</button></div></div><div class="card fluid"><h3 id="unflattenobject" class="section double-padded">unflattenObject<mark class="tag">advanced</mark></h3><div class="section double-padded"><p>Unflatten an object with the paths for keys.</p><p>Use <code>Object.keys(obj)</code> combined with <code>Array.reduce()</code> to convert flattened path node to a leaf node. If the value of a key contains a dot delimiter (<code>.</code>), use <code>Array.split('.')</code>, string transformations and <code>JSON.parse()</code> to create an object, then <code>Object.assign()</code> to create the leaf node. Otherwise, add the appropriate key-value pair to the accumulator object.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">unflattenObject</span> <span class="token operator">=</span> obj <span class="token operator">=></span>
Object<span class="token punctuation">.</span><span class="token function">keys</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> k<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>k<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">'.'</span><span class="token punctuation">)</span> <span class="token operator">!== -</span><span class="token number">1</span><span class="token punctuation">) {</span>
<span class="token keyword">const</span> keys <span class="token operator">=</span> k<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">'.'</span><span class="token punctuation">);</span>