Travis build: 707 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 12:07:56 +00:00
parent 39d46d9fd5
commit c9a1d9301d
2 changed files with 39 additions and 1 deletions

View File

@ -126,6 +126,7 @@
* [`compose`](#compose)
* [`curry`](#curry)
* [`functionName`](#functionname)
* [`memoize`](#memoize)
* [`runPromisesInSeries`](#runpromisesinseries)
* [`sleep`](#sleep)
@ -2176,6 +2177,35 @@ functionName(Math.max); // max (logged in debug channel of console)
<br>[⬆ Back to top](#table-of-contents)
### memoize
Returns the memoized (cached) function.
Use `Object.create(null)` to create an empty object without `Object.prototype` (so that those properties are not resolved if the input value is something like `'hasOwnProperty'`).
Return a function which takes a single argument to be supplied to the memoized function by first checking if the function's output for that specific input value is already cached, or store and return it if not.
```js
const memoize = fn => {
const cache = Object.create(null);
return value => cache[value] || (cache[value] = fn(value));
};
```
<details>
<summary>Examples</summary>
```js
// See the `anagrams` snippet.
const anagramsCached = memoize(anagrams);
anagramsCached('javascript'); // takes a long time
anagramsCached('javascript'); // returns virtually instantly since it's now cached
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### runPromisesInSeries
Runs an array of promises in series.

File diff suppressed because one or more lines are too long