Merge remote-tracking branch 'origin/master'

This commit is contained in:
Angelos Chalaris
2018-01-24 14:40:21 +02:00
3 changed files with 46 additions and 4 deletions

View File

@ -224,6 +224,7 @@ average(1, 2, 3);
* [`composeRight`](#composeright) * [`composeRight`](#composeright)
* [`curry`](#curry) * [`curry`](#curry)
* [`defer`](#defer) * [`defer`](#defer)
* [`delay`](#delay)
* [`functionName`](#functionname) * [`functionName`](#functionname)
* [`memoize`](#memoize) * [`memoize`](#memoize)
* [`negate`](#negate) * [`negate`](#negate)
@ -3360,6 +3361,35 @@ defer(longRunningFunction); // Browser will update the HTML then run the functio
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### defer
Invokes the provided function after `wait` milliseconds.
Use `setTimeout()` to delay execution of `fn`.
Use the spread (`...`) operator to supply the function with an arbitrary number of arguments.
```js
const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
```
<details>
<summary>Examples</summary>
```js
delay(
function(text) {
console.log(text);
},
1000,
'later'
); // Logs 'later' after one second.
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### functionName ### functionName
Logs the name of a function. Logs the name of a function.

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,11 @@ const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
``` ```
```js ```js
delay(function(text) { delay(
function(text) {
console.log(text); console.log(text);
}, 1000, 'later'); // Logs 'later' after one second. },
1000,
'later'
); // Logs 'later' after one second.
``` ```