Travis build: 1100
This commit is contained in:
@ -13,6 +13,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
|
||||
|
||||
|
||||
|
||||
|
||||
const lengthIs4 = checkProp(l => l === 4, 'length');
|
||||
lengthIs4([]); // false
|
||||
lengthIs4([1,2,3,4]); // true
|
||||
|
||||
@ -7,13 +7,15 @@ Collect the object from the array, using `Array.prototype.reduce()`.
|
||||
|
||||
```js
|
||||
const formToObject = form =>
|
||||
Array.from(new FormData(form))
|
||||
.reduce((acc, [key, value]) => ({
|
||||
Array.from(new FormData(form)).reduce(
|
||||
(acc, [key, value]) => ({
|
||||
...acc,
|
||||
[key]: value,
|
||||
}), {})
|
||||
[key]: value
|
||||
}),
|
||||
{}
|
||||
);
|
||||
```
|
||||
|
||||
```js
|
||||
formToObject(document.querySelector('#form')) // { email: 'test@email.com', name: 'Test Name' }
|
||||
formToObject(document.querySelector('#form')); // { email: 'test@email.com', name: 'Test Name' }
|
||||
```
|
||||
|
||||
@ -17,7 +17,7 @@ const sum = pipeAsyncFunctions(
|
||||
x => x + 3,
|
||||
async x => (await x) + 4
|
||||
);
|
||||
(async () => {
|
||||
(async() => {
|
||||
console.log(await sum(5)); // 15 (after one second)
|
||||
})();
|
||||
```
|
||||
|
||||
@ -9,9 +9,9 @@ The `func` is invoked with three arguments (`value, index, array`).
|
||||
const remove = (arr, func) =>
|
||||
Array.isArray(arr)
|
||||
? arr.filter(func).reduce((acc, val) => {
|
||||
arr.splice(arr.indexOf(val), 1);
|
||||
return acc.concat(val);
|
||||
}, [])
|
||||
arr.splice(arr.indexOf(val), 1);
|
||||
return acc.concat(val);
|
||||
}, [])
|
||||
: [];
|
||||
```
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@ Use `Array.prototype.join()` with appropriate argumens to produce an appropriate
|
||||
|
||||
```js
|
||||
const serializeForm = form =>
|
||||
Array.from(new FormData(form), field => field.map(encodeURIComponent).join('=')).join('&')
|
||||
Array.from(new FormData(form), field => field.map(encodeURIComponent).join('=')).join('&');
|
||||
```
|
||||
|
||||
```js
|
||||
serializeForm(document.querySelector('#form')) // email=test%40email.com&name=Test%20Name
|
||||
serializeForm(document.querySelector('#form')); // email=test%40email.com&name=Test%20Name
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user