Skip to content

Commit 8513b73

Browse files
committed
Updates README
1 parent a558bf7 commit 8513b73

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const shouldPaginatize = (postsCount > 10) // Made up verbs are so much fun!
4141

4242
/* Good */
4343
const postsCount = 5
44-
const shouldDisplayPagination = (postsCount > 10)
44+
const hasPagination = (postsCount > 10)
45+
const shouldDisplayPagination = (postsCount > 10) // alternatively
4546
```
4647

4748
## Avoid contractions
@@ -217,6 +218,22 @@ link.addEventListener('click', handleLinkClick)
217218

218219
A domain that a function operates on.
219220

221+
A function is often an action on *something*. It is important to state what is its operable domain, or at least an expected data type.
222+
223+
```js
224+
/* A pure function operating with primitives */
225+
function filter(predicate, list) {
226+
return list.filter(predicate)
227+
}
228+
229+
/* Function operating exactly on posts */
230+
function getRecentPosts(posts) {
231+
return filter(posts, (post) => post.date === Date.now())
232+
}
233+
```
234+
235+
> Note that language-specific assumptions may allow to ommit the context in some cases. For example, in JavaScript it is common that `filter` operates on Array. Adding explicit `filterArray` would be unnecessary.
236+
220237
---
221238

222239
## Prefixes

0 commit comments

Comments
 (0)