Skip to content

Commit 2c4ae49

Browse files
committed
101: big update
1 parent 394ab3d commit 2c4ae49

File tree

4 files changed

+187
-35
lines changed

4 files changed

+187
-35
lines changed

Diff for: 101.md

+146-26
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
---
22
title: 101
33
category: JavaScript libraries
4+
layout: 2017/sheet
5+
updated: 2017-09-21
6+
intro: |
7+
[101](https://www.npmjs.com/package/101) is a JavaScript library for dealing with immutable data in a functional manner.
48
---
59

10+
### Usage
11+
12+
```js
13+
const isObject = require('101/isObject')
14+
isObject({}) // → true
615
```
16+
17+
Every function is exposed as a module.
18+
19+
See: [101](https://github.com/tjmehta/101)
20+
21+
### Type checking
22+
23+
```js
724
isObject({})
825
isString('str')
926
isRegExp(/regexp/)
@@ -15,69 +32,172 @@ isNumber(10.1)
1532
instanceOf(obj, 'string')
1633
```
1734

18-
## Function composition
35+
## Objects
36+
{: .-three-column}
37+
38+
### Example
39+
{: .-prime}
1940

41+
```js
42+
let obj = {}
2043
```
21-
compose(f, g) // x => f(g(x))
22-
curry(f) // x => y => f(x, y)
23-
flip(f) // f(x, y) --> f(y, x)
2444

25-
passAll(f, g) // x => f(x) && g(x)
26-
passAny(f, g) // x => f(x) || g(x)
45+
#### Update
2746

28-
converge(and, [pluck('a'), pluck('b')])(x)
29-
// and(pluck(x, 'a'), pluck(x, 'b'))
47+
```js
48+
obj = put(obj, 'user.name', 'John')
49+
// → { user: { name: 'John' } }
3050
```
3151

32-
## Objects
52+
#### Read
53+
54+
```js
55+
pluck(name, 'user.name')
56+
// → 'John'
57+
```
58+
59+
#### Delete
60+
61+
```js
62+
obj = del(obj, 'user')
63+
// → { }
64+
```
65+
66+
### Getting
3367

3468
```js
35-
del(state, 'user.profile')
36-
put(state, 'user.profile.name', 'john')
3769
pluck(state, 'user.profile.name')
70+
```
3871

39-
omit(state, 'user.profile')
72+
```js
4073
pick(state, ['user', 'ui'])
4174
pick(state, /^_/)
75+
```
76+
77+
`pluck` returns values, `pick` returns subsets of objects.
78+
79+
See:
80+
[pluck](https://github.com/tjmehta/101#pluck),
81+
[pick](https://github.com/tjmehta/101#pick)
82+
83+
### Setting
84+
85+
```js
86+
put(state, 'user.profile.name', 'john')
87+
```
88+
89+
See:
90+
[put](https://github.com/tjmehta/101#put)
91+
92+
### Deleting
93+
94+
```js
95+
del(state, 'user.profile')
96+
omit(state, ['user', 'data'])
97+
```
98+
99+
`omit` is like `del`, but supports multiple keys to be deleted.
42100

101+
See:
102+
[omit](https://github.com/tjmehta/101#omit),
103+
[del](https://github.com/tjmehta/101#del)
104+
105+
### Keypath check
106+
107+
```js
43108
hasKeypaths(state, ['user'])
44109
hasKeypaths(state, { 'user.profile.name': 'john' })
110+
```
111+
112+
See:
113+
[hasKeypaths](https://github.com/tjmehta/101#haskeypaths)
114+
115+
### Get values
45116

117+
```js
46118
values(state)
47119
```
48120

121+
## Functions
122+
123+
### Simple functions
124+
125+
| `and(x, y)` | `x && y` |
126+
| `or(x, y)` | `x || y` |
127+
| `xor(x, y)` | `!(!x && !y) && !(x && y)` |
128+
| `equals(x, y)` | `x === y` |
129+
| `exists(x)` | `!!x` |
130+
| `not(x)` | `!x` |
131+
132+
Useful for function composition.
133+
134+
See:
135+
[and](https://github.com/tjmehta/101#and),
136+
[equals](https://github.com/tjmehta/101#equals),
137+
[exists](https://github.com/tjmehta/101#exists)
138+
139+
### Composition
140+
141+
```js
142+
compose(f, g) // x => f(g(x))
143+
curry(f) // x => y => f(x, y)
144+
flip(f) // f(x, y) --> f(y, x)
145+
```
146+
147+
See:
148+
[compose](https://github.com/tjmehta/101#compose),
149+
[curry](https://github.com/tjmehta/101#curry),
150+
[flip](https://github.com/tjmehta/101#flip)
151+
152+
### And/or
153+
154+
```js
155+
passAll(f, g) // x => f(x) && g(x)
156+
passAny(f, g) // x => f(x) || g(x)
157+
```
158+
159+
See:
160+
[passAll](https://github.com/tjmehta/101#passall),
161+
[passAny](https://github.com/tjmehta/101#passany)
162+
163+
### Converge
164+
165+
```js
166+
converge(and, [pluck('a'), pluck('b')])(x)
167+
```
168+
169+
```js
170+
// → and(pluck(x, 'a'), pluck(x, 'b'))
171+
```
172+
173+
See:
174+
[converge](https://github.com/tjmehta/101#converge)
175+
49176
## Arrays
50177

178+
### Finding
179+
51180
```js
52181
find(list, x => x.y === 2)
53182
findIndex(list, x => ...)
54183
includes(list, 'item')
55184
last(list)
56-
57-
groupBy(list, 'id')
58-
indexBy(list, 'id')
59185
```
60186

61187
```js
62188
find(list, hasProps('id'))
63189
```
64190

65-
## Simple
66-
67-
Useful for function composition.
191+
### Grouping
68192

69193
```js
70-
and(x, y) // x && y
71-
or(x, y) // x || y
72-
xor(x, y) // !(!x && !y) && !(x && y)
73-
equal(x, y) // x === y
74-
exists(x) // !!x
75-
not(x) // !x
194+
groupBy(list, 'id')
195+
indexBy(list, 'id')
76196
```
77197

78198
## Examples
79199

80-
Function composition:
200+
### Function composition
81201

82202
```js
83203
isFloat = passAll(isNumber, compose(isInteger, not))
@@ -92,4 +212,4 @@ doStuffForce = curry(flip(doStuff))({ force: true })
92212

93213
## Reference
94214

95-
<https://github.com/tjmehta/101>
215+
- <https://github.com/tjmehta/101>

Diff for: CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ make
4343
{: .-four-column}
4444
{: .-six-column}
4545

46+
`h3` sections can have:
47+
48+
pre
49+
p
50+
ul
51+
table
52+
h4
53+
4654
## Frontmatter
4755

4856
Each sheet supports these metadata:

Diff for: _sass/2017/components/h3-section.scss

+14
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@
111111
margin: 0;
112112
}
113113

114+
/* Headings in between bodies */
115+
& > h4 {
116+
@include font-size(-1);
117+
margin: 0;
118+
padding: 4px 16px;
119+
font-weight: normal;
120+
background: $gray-bg;
121+
color: $gray-text;
122+
123+
& + * {
124+
border-top: solid 1px $line-color;
125+
}
126+
}
127+
114128
/* Description paragraphs */
115129
& > pre ~ p,
116130
& > ul ~ p,

Diff for: react.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -394,30 +394,40 @@ import PropTypes from 'prop-types'
394394

395395
See: [Typechecking with PropTypes](https://facebook.github.io/react/docs/typechecking-with-proptypes.html)
396396

397-
| PropType | Description |
398-
| --- | --- |
399397
| `any` | Anything |
400-
| --- | --- |
398+
399+
#### Basic
400+
401401
| `string` | |
402402
| `number` | |
403403
| `func` | Function |
404404
| `bool` | True or false |
405-
| --- | --- |
405+
406+
#### Enum
407+
406408
| `oneOf`_(any)_ | Enum types |
407409
| `oneOfType`_(type array)_ | Union |
408-
| --- | --- |
410+
411+
#### Array
412+
409413
| `array` | |
410414
| `arrayOf`_(...)_ | |
411-
| --- | --- |
415+
416+
#### Object
417+
412418
| `object` | |
413419
| `objectOf`_(...)_ | Object with values of a certain type |
414420
| `instanceOf`_(...)_ | Instance of a class |
415421
| `shape`_(...)_ | |
416-
| --- | --- |
422+
423+
#### Elements
424+
417425
| `element` | React element |
418426
| `node` | DOM node |
419-
| --- | --- |
420-
| `.isRequired` | Required |
427+
428+
#### Required
429+
430+
| `(···).isRequired` | Required |
421431

422432
### Basic types
423433

0 commit comments

Comments
 (0)