Build README
This commit is contained in:
16
README.md
16
README.md
@ -12,6 +12,7 @@
|
||||
* [Average of array of numbers](#average-of-array-of-numbers)
|
||||
* [Capitalize first letter of every word](#capitalize-first-letter-of-every-word)
|
||||
* [Capitalize first letter](#capitalize-first-letter)
|
||||
* [Chain asynchronous functions](#chain-asynchronous-functions)
|
||||
* [Check for palindrome](#check-for-palindrome)
|
||||
* [Chunk array](#chunk-array)
|
||||
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
|
||||
@ -110,6 +111,21 @@ const capitalize = (str, lowerRest = false) =>
|
||||
// capitalize('myName', true) -> 'Myname'
|
||||
```
|
||||
|
||||
### Chain asynchronous functions
|
||||
|
||||
Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed.
|
||||
|
||||
```js
|
||||
const chainAsync = fns => { let curr = 0; const next = () => fns[curr++](next); next(); }
|
||||
/*
|
||||
chainAsync([
|
||||
next => { console.log('0 seconds'); setTimeout(next, 1000); },
|
||||
next => { console.log('1 second'); setTimeout(next, 1000); },
|
||||
next => { console.log('2 seconds'); }
|
||||
])
|
||||
*/
|
||||
```
|
||||
|
||||
### Check for palindrome
|
||||
|
||||
Convert string `toLowerCase()` and use `replace()` to remove non-alphanumeric characters from it.
|
||||
|
||||
@ -8,7 +8,7 @@ const chainAsync = fns => { let curr = 0; const next = () => fns[curr++](next);
|
||||
chainAsync([
|
||||
next => { console.log('0 seconds'); setTimeout(next, 1000); },
|
||||
next => { console.log('1 second'); setTimeout(next, 1000); },
|
||||
next => { console.log('2 seconds');}
|
||||
next => { console.log('2 seconds'); }
|
||||
])
|
||||
*/
|
||||
```
|
||||
Reference in New Issue
Block a user