diff --git a/README.md b/README.md index a9e22e65c..5dd3b693c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # 30 seconds of code -[![License](https://img.shields.io/badge/license-CC0--1.0-blue.svg)](https://github.com/30-seconds/30-seconds-of-code/blob/master/LICENSE) [![npm Downloads](https://img.shields.io/npm/dt/30-seconds-of-code.svg)](https://www.npmjs.com/package/30-seconds-of-code) [![npm Version](https://img.shields.io/npm/v/30-seconds-of-code.svg)](https://www.npmjs.com/package/30-seconds-of-code) [![Known Vulnerabilities](https://snyk.io/test/github/30-seconds/30-seconds-of-code/badge.svg?targetFile=package.json)](https://snyk.io/test/github/30-seconds/30-seconds-of-code?targetFile=package.json)
+[![License](https://img.shields.io/badge/license-CC0--1.0-blue.svg)](https://github.com/30-seconds/30-seconds-of-code/blob/master/LICENSE) [![npm Downloads](https://img.shields.io/npm/dt/30-seconds-of-code.svg)](https://www.npmjs.com/package/30-seconds-of-code) [![npm Version](https://img.shields.io/npm/v/30-seconds-of-code.svg)](https://www.npmjs.com/package/30-seconds-of-code) [![Known Vulnerabilities](https://snyk.io/test/github/30-seconds/30-seconds-of-code/badge.svg?targetFile=package.json)](https://snyk.io/test/github/30-seconds/30-seconds-of-code?targetFile=package.json)
[![Travis Build](https://travis-ci.com/30-seconds/30-seconds-of-code.svg?branch=master)](https://travis-ci.com/30-seconds/30-seconds-of-code) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6ab7791fb1ea40b4a576d658fb96807f)](https://www.codacy.com/app/Chalarangelo/30-seconds-of-code?utm_source=github.com&utm_medium=referral&utm_content=30-seconds/30-seconds-of-code&utm_campaign=Badge_Grade) [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg)](https://github.com/Flet/semistandard)
[![Awesome](https://awesome.re/badge.svg)](https://awesome.re) [![ProductHunt](https://img.shields.io/badge/producthunt-vote-orange.svg)](https://www.producthunt.com/posts/30-seconds-of-code) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) @@ -20,10 +20,10 @@ * [30 Seconds of CSS](https://30-seconds.github.io/30-seconds-of-css/) * [30 Seconds of Interviews](https://30secondsofinterviews.org/) * [30 Seconds of React](https://github.com/30-seconds/30-seconds-of-react) -* [30 Seconds of Python](https://github.com/kriadmin/30-seconds-of-python-code) _(unofficial)_ -* [30 Seconds of PHP](https://github.com/appzcoder/30-seconds-of-php-code) _(unofficial)_ +* [30 Seconds of Python](https://github.com/30-seconds/30-seconds-of-python-code) +* [30 Seconds of PHP](https://github.com/30-seconds/30-seconds-of-php-code) +* [30 Seconds of Knowledge](https://chrome.google.com/webstore/detail/30-seconds-of-knowledge/mmgplondnjekobonklacmemikcnhklla) * [30 Seconds of Kotlin](https://github.com/IvanMwiruki/30-seconds-of-kotlin) _(unofficial)_ -* [30 Seconds of Knowledge](https://chrome.google.com/webstore/detail/30-seconds-of-knowledge/mmgplondnjekobonklacmemikcnhklla) _(unofficial)_ #### Package @@ -531,12 +531,12 @@ const firstTwoMax = ary(Math.max, 2);
[⬆ Back to top](#contents) -### call - -Given a key and a set of arguments, call them when given a context. Primarily useful in composition. - -Use a closure to call a stored key with stored arguments. - +### call + +Given a key and a set of arguments, call them when given a context. Primarily useful in composition. + +Use a closure to call a stored key with stored arguments. + ```js const call = (key, ...args) => context => context[key](...args); ``` @@ -552,18 +552,18 @@ const map = call.bind(null, 'map'); Promise.resolve([1, 2, 3]) .then(map(x => 2 * x)) .then(console.log); // [ 2, 4, 6 ] -``` +```
[⬆ Back to top](#contents) -### collectInto - -Changes a function that accepts an array into a variadic function. - -Given a function, return a closure that collects all inputs into an array-accepting function. - +### collectInto + +Changes a function that accepts an array into a variadic function. + +Given a function, return a closure that collects all inputs into an array-accepting function. + ```js const collectInto = fn => (...args) => fn(args); ``` @@ -577,18 +577,18 @@ let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds) -``` +```
[⬆ Back to top](#contents) -### flip - -Flip takes a function as an argument, then makes the first argument the last. - -Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest. - +### flip + +Flip takes a function as an argument, then makes the first argument the last. + +Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest. + ```js const flip = fn => (first, ...rest) => fn(...rest, first); ``` @@ -604,7 +604,7 @@ let mergePerson = mergeFrom.bind(null, a); mergePerson(b); // == b b = {}; Object.assign(b, a); // == b -``` +``` @@ -767,12 +767,12 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c']
[⬆ Back to top](#contents) -### spreadOver - -Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. - -Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function. - +### spreadOver + +Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. + +Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function. + ```js const spreadOver = fn => argsArr => fn(...argsArr); ``` @@ -783,7 +783,7 @@ const spreadOver = fn => argsArr => fn(...argsArr); ```js const arrayMax = spreadOver(Math.max); arrayMax([1, 2, 3]); // 3 -``` +``` @@ -1262,12 +1262,12 @@ everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ]
[⬆ Back to top](#contents) -### filterFalsy - -Filters out the falsy values in an array. - -Use `Array.prototype.filter()` to get an array containing only truthy values. - +### filterFalsy + +Filters out the falsy values in an array. + +Use `Array.prototype.filter()` to get an array containing only truthy values. + ```js const filterFalsy = arr => arr.filter(Boolean); ``` @@ -1277,7 +1277,7 @@ const filterFalsy = arr => arr.filter(Boolean); ```js filterFalsy(['', true, {}, false, 'sample', 1, 0]); // [true, {}, 'sample', 1] -``` +``` @@ -3283,7 +3283,7 @@ bottomVisible(); // true ⚠️ **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. +Copy a string to the clipboard. Only works as a result of user action (i.e. inside a `click` event listener). Create a new `