about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--js/b/b.js16
-rw-r--r--js/b/tests.js28
2 files changed, 22 insertions, 22 deletions
diff --git a/js/b/b.js b/js/b/b.js
index ee33eef..04959c4 100644
--- a/js/b/b.js
+++ b/js/b/b.js
@@ -20,17 +20,17 @@
 //
 */
 
-// b is for useful stuff 
+// b is for useful stuff
 
-// pipe: Runs functions from left to right.
-// compose: Runs functions from right to left.
-// identity: Returns whatever you give it as is.
-// curry: Converts a function to its curried form.
+// curry: Converts a function to its curried form, allowing for partial application.
+// pipe: Runs functions from left to right, passing the result of one to the next.
+// compose: Runs functions from right to left, passing the result of one to the next.
+// identity: Returns whatever you give it as is. Useful for composition...sometimes.
 // match: Creates a curried function to match a regular expression in a string.
-// replace: Creates a curried function to replace parts of a string.
-// filter: Curried array filtering.
+// replace: Creates a curried function to replace parts of a string, based on a regex or substring.
+// filter: Curried array filtering by a predicate function.
 // map: Curried array mapping.
-// deepMap: Curried recursive mapping for nested arrays or matrices.
+// deepMap: Curried recursive mapping for nested arrays or matrices, of any shape.
 
 'use strict'
 
diff --git a/js/b/tests.js b/js/b/tests.js
index 62ebf4a..5b8ee87 100644
--- a/js/b/tests.js
+++ b/js/b/tests.js
@@ -1,39 +1,39 @@
 import b from './b';
 
-// Tests! 
+
+// curry
+const add = (x, y) => x + y;
+const curriedAdd = b.curry(add);
+console.assert(curriedAdd(3)(4) === 7, 'Unexpected result from curried function');
+
 // pipe
 const addOne = (x) => x + 1;
 const double = (x) => x * 2;
-console.assert(b.pipe(addOne, double)(3) === 8, 'Test for pipe failed');
+console.assert(b.pipe(addOne, double)(3) === 8, 'Unexpected result from pipe');
 
 // compose
-console.assert(b.compose(double, addOne)(3) === 8, 'Test for compose failed');
+console.assert(b.compose(double, addOne)(3) === 8, 'Unexpected result from compose');
 
 // identity
-console.assert(b.identity(5) === 5, 'Test for identity failed');
-
-// curry
-const add = (x, y) => x + y;
-const curriedAdd = b.curry(add);
-console.assert(curriedAdd(3)(4) === 7, 'Test for curry failed');
+console.assert(b.identity(5) === 5, 'Unexpected result from identity');
 
 // match
 const matchDigits = b.match()(/\d+/g);
-console.assert(JSON.stringify(matchDigits('a1b2c3')) === JSON.stringify(['1', '2', '3']), 'Test for match failed');
+console.assert(JSON.stringify(matchDigits('a1b2c3')) === JSON.stringify(['1', '2', '3']), 'Unexpected result from match');
 
 // replace
 const censor = b.replace()(/badword/g, '****');
-console.assert(censor('This is a badword in a sentence.') === 'This is a **** in a sentence.', 'Test for replace failed');
+console.assert(censor('This is a badword in a sentence.') === 'This is a **** in a sentence.', 'Unexpected result from replace');
 
 // filter
 const isEven = (x) => x % 2 === 0;
 const filterEvens = b.filter()(isEven);
-console.assert(JSON.stringify(filterEvens([1, 2, 3, 4])) === JSON.stringify([2, 4]), 'Test for filter failed');
+console.assert(JSON.stringify(filterEvens([1, 2, 3, 4])) === JSON.stringify([2, 4]), 'Unexpected result from filter');
 
 // map
 const mapDoubles = b.map()(double);
-console.assert(JSON.stringify(mapDoubles([1, 2, 3])) === JSON.stringify([2, 4, 6]), 'Test for map failed');
+console.assert(JSON.stringify(mapDoubles([1, 2, 3])) === JSON.stringify([2, 4, 6]), 'Unexpected result from map');
 
 // deepMap
 const nestedArray = [1, [2, [3, 4]], [5, 6]];
-console.assert(JSON.stringify(b.deepMap()(double, nestedArray)) === JSON.stringify([2, [4, [6, 8]], [10, 12]]), 'Test for deepMap failed');
\ No newline at end of file
+console.assert(JSON.stringify(b.deepMap()(double, nestedArray)) === JSON.stringify([2, [4, [6, 8]], [10, 12]]), 'Unexpected result from deepMap');
\ No newline at end of file
f1dde2c287ebe84ef37'>a654e4ec ^
e5c11a51 ^
3e1349d2 ^
9e751bb8 ^

dcc060c7 ^

a654e4ec ^



e5c11a51 ^






















a654e4ec ^

dcc060c7 ^
e5c11a51 ^
a654e4ec ^
204dae92 ^






6c52e24e ^
204dae92 ^
9e751bb8 ^

204dae92 ^

9e751bb8 ^

204dae92 ^




6c52e24e ^
204dae92 ^
9e751bb8 ^

204dae92 ^

9e751bb8 ^

204dae92 ^




6c52e24e ^
204dae92 ^
9e751bb8 ^
204dae92 ^

9e751bb8 ^

204dae92 ^


6c52e24e ^
204dae92 ^
124c6764 ^
6c52e24e ^
204dae92 ^

6c52e24e ^
204dae92 ^




124c6764 ^
204dae92 ^


124c6764 ^

204dae92 ^



6c52e24e ^
204dae92 ^


201458e3 ^
124c6764 ^

201458e3 ^
6c52e24e ^

204dae92 ^


6c52e24e ^
204dae92 ^


6c52e24e ^
204dae92 ^


201458e3 ^
124c6764 ^

201458e3 ^
6c52e24e ^

204dae92 ^









201458e3 ^
204dae92 ^





dcc060c7 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175