1 | ## API
|
2 |
|
3 | ### defaultTo
|
4 |
|
5 | `a -> b -> a | b`
|
6 |
|
7 | ```javascript
|
8 | var hasDefault = huan.defaultTo(42);
|
9 | hasDefault(null); // 42
|
10 | hasDefault(20); // 20
|
11 | ```
|
12 |
|
13 | ### chunk
|
14 |
|
15 | `Number n => n -> [a] -> [[a]]`
|
16 |
|
17 | ### flatMap
|
18 |
|
19 | `(a -> [a]) -> [a] -> [a]`
|
20 |
|
21 | ### difference
|
22 |
|
23 | `[a] -> [a] - [a]`
|
24 |
|
25 | ### mapObj
|
26 |
|
27 | ### filterObj
|
28 |
|
29 | ### reduceObj
|
30 |
|
31 | ### omit
|
32 |
|
33 | `[k] -> {k: v} -> {k: v}`
|
34 |
|
35 | ### pick
|
36 |
|
37 | `[k] -> {k: v} -> {k: v}`
|
38 |
|
39 | ### pluck
|
40 |
|
41 | `String a => a -> [{a: v}] -> [v]`
|
42 |
|
43 | ### project
|
44 |
|
45 | `[k] -> [{k: v}] -> [{k: v}]`
|
46 |
|
47 | ### pair
|
48 |
|
49 | `[a] -> [[a]]`
|
50 |
|
51 | ### patch
|
52 |
|
53 | `v -> [k] -> {k: v} -> {k: v}`
|
54 |
|
55 | ### valueIf
|
56 |
|
57 | `(a -> Bool) -> {k: v} -> [v]`
|
58 |
|
59 | ### values
|
60 |
|
61 | `{k: v} -> [v]`
|
62 |
|
63 | ### groupBy
|
64 |
|
65 | `String k => (a -> k) -> [a] -> {k: [a]}`
|
66 |
|
67 | Splits a list into sub-lists stored in an object, based on the result of calling
|
68 | a String-returning function on each element,
|
69 | and grouping the results according to values returned.
|
70 |
|
71 | Dispatches to the groupBy method of the second argument, if present.
|
72 |
|
73 | Acts as a transducer if a transformer is given in list position.
|
74 |
|
75 | ```javascript
|
76 | huan.groupBy(function(lang) {
|
77 | return (lang.name === 'js' || lang.name === 'php') ? 'not-typed' : 'type';
|
78 | },
|
79 | {
|
80 | 'not-typed': [{name: 'js'}, {name: 'php'}],
|
81 | typed: [{name: 'scala'}, {name: 'haskell'}]
|
82 | }
|
83 | );
|
84 | ```
|
85 |
|