forked from extern/naming-cheatsheet
Updates README
This commit is contained in:
25
README.md
25
README.md
@ -122,6 +122,8 @@ function getFruitsCount() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> See also [compose](#compose).
|
||||||
|
|
||||||
### `set`
|
### `set`
|
||||||
Declaratively sets a variable with value `A` to value `B`.
|
Declaratively sets a variable with value `A` to value `B`.
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ console.log(fruits) // 5
|
|||||||
Requests for a data, which takes time (i.e. async request).
|
Requests for a data, which takes time (i.e. async request).
|
||||||
```js
|
```js
|
||||||
function fetchPosts(postCount) {
|
function fetchPosts(postCount) {
|
||||||
return fetch('https://api.dev/posts', { ... })
|
return fetch('https://api.dev/posts', {...})
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -167,19 +169,16 @@ Removes something *from* somewhere.
|
|||||||
For example, if you have a collection of selected filters on a search page, removing one of them from the collection is `removeFilter`, **not** `deleteFilter` (and this is how you would naturally say it in English as well):
|
For example, if you have a collection of selected filters on a search page, removing one of them from the collection is `removeFilter`, **not** `deleteFilter` (and this is how you would naturally say it in English as well):
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const selectedFilters = ['price', 'availability', 'size']
|
function removeFilter(filterName, filters) {
|
||||||
|
return filters.filter(name => name !== filterName)
|
||||||
function removeFilter(filterName) {
|
|
||||||
const filterIndex = selectedFilters.indexOf(filterName)
|
|
||||||
|
|
||||||
if (filterIndex !== -1) {
|
|
||||||
selectedFilters.splice(filterIndex, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return selectedFilters
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedFilters = ['price', 'availability', 'size']
|
||||||
|
removeFilter('price', selectedFilters)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> See also [delete](#delete).
|
||||||
|
|
||||||
### `delete`
|
### `delete`
|
||||||
Completely erazes something from the realms of existance.
|
Completely erazes something from the realms of existance.
|
||||||
|
|
||||||
@ -191,6 +190,8 @@ function deletePost(id) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> See also [remove](#remove).
|
||||||
|
|
||||||
### `compose`
|
### `compose`
|
||||||
Creates a new data from the existing one. Mostly applicable to strings or objects.
|
Creates a new data from the existing one. Mostly applicable to strings or objects.
|
||||||
|
|
||||||
@ -200,6 +201,8 @@ function composePageUrl(pageName, pageId) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> See also [get](#get).
|
||||||
|
|
||||||
### `handle`
|
### `handle`
|
||||||
Handles a dedicated action. Often used in naming the callback methods.
|
Handles a dedicated action. Often used in naming the callback methods.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user