Merge pull request #210 from Kladdkaka/master

Changing _ to () :)
This commit is contained in:
Angelos Chalaris
2017-12-17 13:01:12 +02:00
committed by GitHub
5 changed files with 6 additions and 5 deletions

View File

@ -55,7 +55,8 @@ Here's what you can do to help:
- `i` for indexes.
- `func` for function arguments.
- `nums` for arrays of numbers.
- Use `_` if your function takes no arguments or if an argument inside some function (e.g. `Array.reduce()`) is not used anywhere in your code.
- Use `()` if your function takes no arguments.
- Use `_` if an argument inside some function (e.g. `Array.reduce()`) is not used anywhere in your code.
- Specify default parameters for arguments, if necessary. It is preferred to put default parameters last unless you have pretty good reason not to.
- If your snippet's function takes variadic arguments, use `..args` (although in certain cases, it might be needed to use a different name).
- If your snippet function's body is a single statement, omit the `return` keyword and use an expression instead.

View File

@ -3,7 +3,7 @@
Use `crypto` API to generate a UUID, compliant with [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) version 4.
```js
const uuid = _ =>
const uuid = () =>
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);

View File

@ -3,7 +3,7 @@
Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible.
```js
const bottomVisible = _ =>
const bottomVisible = () =>
document.documentElement.clientHeight + window.scrollY >= document.documentElement.scrollHeight || document.documentElement.clientHeight;
// bottomVisible() -> true
```

View File

@ -3,6 +3,6 @@
Use `window.location.href` to get current URL.
```js
const currentUrl = _ => window.location.href;
const currentUrl = () => window.location.href;
// currentUrl() -> 'https://google.com'
```

View File

@ -4,7 +4,7 @@ Get distance from top using `document.documentElement.scrollTop` or `document.bo
Scroll by a fraction of the distance from top. Use `window.requestAnimationFrame()` to animate the scrolling.
```js
const scrollToTop = _ => {
const scrollToTop = () => {
const c = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
window.requestAnimationFrame(scrollToTop);