diff --git a/README.md b/README.md index 3495d0902..18def8a0e 100644 --- a/README.md +++ b/README.md @@ -680,7 +680,7 @@ const sum = pipeAsyncFunctions( x => x + 3, async x => (await x) + 4 ); -(async() => { +(async () => { console.log(await sum(5)); // 15 (after one second) })(); ``` @@ -1769,8 +1769,8 @@ const join = (arr, separator = ',', end = separator) => i === arr.length - 2 ? acc + val + end : i === arr.length - 1 - ? acc + val - : acc + val + separator, + ? acc + val + : acc + val + separator, '' ); ``` @@ -2037,10 +2037,10 @@ partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active': ### permutations ![advanced](/advanced.svg) -⚠️ **WARNING**: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations. - Generates all permutations of an array's elements (contains duplicates). +⚠️ **WARNING**: This function's execution time increases exponentially with each array element. Anything more than 8 to 10 entries will cause your browser to hang as it tries to solve all the different combinations. + Use recursion. For each element in the given array, create all the partial permutations for the rest of its elements. Use `Array.prototype.map()` to combine the element with each partial permutation, then `Array.prototype.reduce()` to combine all permutations in one array. @@ -3223,11 +3223,11 @@ bottomVisible(); // true ### copyToClipboard ![advanced](/advanced.svg) -⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard). - Copy a string to the clipboard. Only works as a result of user action (i.e. inside a `click` event listener). +⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard). + Create a new `