Travis build: 1100

This commit is contained in:
30secondsofcode
2019-04-08 05:41:51 +00:00
parent 1654380bb5
commit 27b26630ab
22 changed files with 122 additions and 36 deletions

View File

@ -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

View File

@ -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' }
```

View File

@ -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)
})();
```

View File

@ -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);
}, [])
: [];
```

View File

@ -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
```