kareem 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +2 -0
- package/CHANGELOG.md +790 -0
- package/index.js +65 -10
- package/package.json +6 -15
- package/test/misc.test.js +38 -0
- package/test/post.test.js +15 -2
- package/test/pre.test.js +13 -0
package/.travis.yml
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
<a name="2.3.0"></a>
|
|
6
|
+
## 2.3.0 (2018-09-24)
|
|
7
|
+
|
|
8
|
+
* chore(release): 2.2.3 ([c8f2695](https://github.com/vkarpov15/kareem/commit/c8f2695))
|
|
9
|
+
* chore(release): 2.2.4 ([a377a4f](https://github.com/vkarpov15/kareem/commit/a377a4f))
|
|
10
|
+
* chore(release): 2.2.5 ([5a495e3](https://github.com/vkarpov15/kareem/commit/5a495e3))
|
|
11
|
+
* fix(filter): copy async pres correctly with `filter()` ([1b1ed8a](https://github.com/vkarpov15/kareem/commit/1b1ed8a)), closes [Automattic/mongoose#3054](https://github.com/Automattic/mongoose/issues/3054)
|
|
12
|
+
* feat: add filter() function ([1f641f4](https://github.com/vkarpov15/kareem/commit/1f641f4))
|
|
13
|
+
* feat: support storing options on pre and post hooks ([59220b9](https://github.com/vkarpov15/kareem/commit/59220b9))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<a name="2.2.3"></a>
|
|
18
|
+
## <small>2.2.3 (2018-09-10)</small>
|
|
19
|
+
|
|
20
|
+
* chore: release 2.2.3 ([af653a3](https://github.com/vkarpov15/kareem/commit/af653a3))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<a name="2.2.2"></a>
|
|
25
|
+
## <small>2.2.2 (2018-09-10)</small>
|
|
26
|
+
|
|
27
|
+
* chore: release 2.2.2 ([3f0144d](https://github.com/vkarpov15/kareem/commit/3f0144d))
|
|
28
|
+
* fix: allow merge() to not clone ([e628d65](https://github.com/vkarpov15/kareem/commit/e628d65))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<a name="2.2.1"></a>
|
|
33
|
+
## <small>2.2.1 (2018-06-05)</small>
|
|
34
|
+
|
|
35
|
+
* chore: release 2.2.1 ([4625a64](https://github.com/vkarpov15/kareem/commit/4625a64))
|
|
36
|
+
* chore: remove lockfile from git ([7f3e4e6](https://github.com/vkarpov15/kareem/commit/7f3e4e6))
|
|
37
|
+
* fix: handle numAsync correctly when merging ([fef8e7e](https://github.com/vkarpov15/kareem/commit/fef8e7e))
|
|
38
|
+
* test: repro issue with not copying numAsync ([952d9db](https://github.com/vkarpov15/kareem/commit/952d9db))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
<a name="2.2.0"></a>
|
|
43
|
+
## 2.2.0 (2018-06-05)
|
|
44
|
+
|
|
45
|
+
* chore: release 2.2.0 ([ff9ad03](https://github.com/vkarpov15/kareem/commit/ff9ad03))
|
|
46
|
+
* fix: use maps instead of objects for _pres and _posts so `toString()` doesn't get reported as having ([55df303](https://github.com/vkarpov15/kareem/commit/55df303)), closes [Automattic/mongoose#6538](https://github.com/Automattic/mongoose/issues/6538)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<a name="2.1.0"></a>
|
|
51
|
+
## 2.1.0 (2018-05-16)
|
|
52
|
+
|
|
53
|
+
* chore: release 2.1.0 ([ba5f1bc](https://github.com/vkarpov15/kareem/commit/ba5f1bc))
|
|
54
|
+
* feat: add option to check wrapped function return value for promises ([c9d7dd1](https://github.com/vkarpov15/kareem/commit/c9d7dd1))
|
|
55
|
+
* refactor: use const in wrap() ([0fc21f9](https://github.com/vkarpov15/kareem/commit/0fc21f9))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
<a name="2.0.7"></a>
|
|
60
|
+
## <small>2.0.7 (2018-04-28)</small>
|
|
61
|
+
|
|
62
|
+
* chore: release 2.0.7 ([0bf91e6](https://github.com/vkarpov15/kareem/commit/0bf91e6))
|
|
63
|
+
* feat: add `hasHooks()` ([225f18d](https://github.com/vkarpov15/kareem/commit/225f18d)), closes [Automattic/mongoose#6385](https://github.com/Automattic/mongoose/issues/6385)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<a name="2.0.6"></a>
|
|
68
|
+
## <small>2.0.6 (2018-03-22)</small>
|
|
69
|
+
|
|
70
|
+
* chore: release 2.0.6 ([f3d406b](https://github.com/vkarpov15/kareem/commit/f3d406b))
|
|
71
|
+
* fix(wrap): ensure fast path still wraps function in `nextTick()` for chaining ([7000494](https://github.com/vkarpov15/kareem/commit/7000494)), closes [Automattic/mongoose#6250](https://github.com/Automattic/mongoose/issues/6250) [dsanel/mongoose-delete#36](https://github.com/dsanel/mongoose-delete/issues/36)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
<a name="2.0.5"></a>
|
|
76
|
+
## <small>2.0.5 (2018-02-22)</small>
|
|
77
|
+
|
|
78
|
+
* chore: release 2.0.5 ([3286612](https://github.com/vkarpov15/kareem/commit/3286612))
|
|
79
|
+
* perf(createWrapper): don't create wrapper if there are no hooks ([5afc5b9](https://github.com/vkarpov15/kareem/commit/5afc5b9)), closes [Automattic/mongoose#6126](https://github.com/Automattic/mongoose/issues/6126)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
<a name="2.0.4"></a>
|
|
84
|
+
## <small>2.0.4 (2018-02-08)</small>
|
|
85
|
+
|
|
86
|
+
* chore: release 2.0.4 ([2ab0293](https://github.com/vkarpov15/kareem/commit/2ab0293))
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<a name="2.0.3"></a>
|
|
91
|
+
## <small>2.0.3 (2018-02-01)</small>
|
|
92
|
+
|
|
93
|
+
* chore: release 2.0.3 ([3c1abe5](https://github.com/vkarpov15/kareem/commit/3c1abe5))
|
|
94
|
+
* fix: use process.nextTick() re: Automattic/mongoose#6074 ([e5bfe33](https://github.com/vkarpov15/kareem/commit/e5bfe33)), closes [Automattic/mongoose#6074](https://github.com/Automattic/mongoose/issues/6074)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
<a name="2.0.2"></a>
|
|
99
|
+
## <small>2.0.2 (2018-01-24)</small>
|
|
100
|
+
|
|
101
|
+
* chore: fix license ([a9d755c](https://github.com/vkarpov15/kareem/commit/a9d755c)), closes [#10](https://github.com/vkarpov15/kareem/issues/10)
|
|
102
|
+
* chore: release 2.0.2 ([fe87ab6](https://github.com/vkarpov15/kareem/commit/fe87ab6))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<a name="2.0.1"></a>
|
|
107
|
+
## <small>2.0.1 (2018-01-09)</small>
|
|
108
|
+
|
|
109
|
+
* chore: release 2.0.1 with lockfile bump ([09c44fb](https://github.com/vkarpov15/kareem/commit/09c44fb))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<a name="2.0.0"></a>
|
|
114
|
+
## 2.0.0 (2018-01-09)
|
|
115
|
+
|
|
116
|
+
* chore: bump marked re: security ([cc564a9](https://github.com/vkarpov15/kareem/commit/cc564a9))
|
|
117
|
+
* chore: release 2.0.0 ([f511d1c](https://github.com/vkarpov15/kareem/commit/f511d1c))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
<a name="2.0.0-rc5"></a>
|
|
122
|
+
## 2.0.0-rc5 (2017-12-23)
|
|
123
|
+
|
|
124
|
+
* chore: fix build on node 4+5 ([6dac5a4](https://github.com/vkarpov15/kareem/commit/6dac5a4))
|
|
125
|
+
* chore: fix built on node 4 + 5 again ([434ef0a](https://github.com/vkarpov15/kareem/commit/434ef0a))
|
|
126
|
+
* chore: release 2.0.0-rc5 ([25a32ee](https://github.com/vkarpov15/kareem/commit/25a32ee))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<a name="2.0.0-rc4"></a>
|
|
131
|
+
## 2.0.0-rc4 (2017-12-22)
|
|
132
|
+
|
|
133
|
+
* chore: release 2.0.0-rc4 ([49fc083](https://github.com/vkarpov15/kareem/commit/49fc083))
|
|
134
|
+
* BREAKING CHANGE: deduplicate when merging hooks re: Automattic/mongoose#2945 ([d458573](https://github.com/vkarpov15/kareem/commit/d458573)), closes [Automattic/mongoose#2945](https://github.com/Automattic/mongoose/issues/2945)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
<a name="2.0.0-rc3"></a>
|
|
139
|
+
## 2.0.0-rc3 (2017-12-22)
|
|
140
|
+
|
|
141
|
+
* chore: release 2.0.0-rc3 ([adaaa00](https://github.com/vkarpov15/kareem/commit/adaaa00))
|
|
142
|
+
* feat: support returning promises from middleware functions ([05b4480](https://github.com/vkarpov15/kareem/commit/05b4480)), closes [Automattic/mongoose#3779](https://github.com/Automattic/mongoose/issues/3779)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<a name="2.0.0-rc2"></a>
|
|
147
|
+
## 2.0.0-rc2 (2017-12-21)
|
|
148
|
+
|
|
149
|
+
* chore: release 2.0.0-rc2 ([76325fa](https://github.com/vkarpov15/kareem/commit/76325fa))
|
|
150
|
+
* fix: ensure next() and done() run in next tick ([6c20684](https://github.com/vkarpov15/kareem/commit/6c20684))
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
<a name="2.0.0-rc1"></a>
|
|
155
|
+
## 2.0.0-rc1 (2017-12-21)
|
|
156
|
+
|
|
157
|
+
* chore: improve test coverage re: Automattic/mongoose#3232 ([7b45cf0](https://github.com/vkarpov15/kareem/commit/7b45cf0)), closes [Automattic/mongoose#3232](https://github.com/Automattic/mongoose/issues/3232)
|
|
158
|
+
* chore: release 2.0.0-rc1 ([9b83f52](https://github.com/vkarpov15/kareem/commit/9b83f52))
|
|
159
|
+
* BREAKING CHANGE: report sync exceptions as errors, only allow calling next() and done() once ([674adcc](https://github.com/vkarpov15/kareem/commit/674adcc)), closes [Automattic/mongoose#3483](https://github.com/Automattic/mongoose/issues/3483)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
<a name="2.0.0-rc0"></a>
|
|
164
|
+
## 2.0.0-rc0 (2017-12-17)
|
|
165
|
+
|
|
166
|
+
* chore: release 2.0.0-rc0 ([16b44b5](https://github.com/vkarpov15/kareem/commit/16b44b5))
|
|
167
|
+
* BREAKING CHANGE: drop support for node < 4 ([9cbb8c7](https://github.com/vkarpov15/kareem/commit/9cbb8c7))
|
|
168
|
+
* BREAKING CHANGE: remove useLegacyPost and add several new features ([6dd8531](https://github.com/vkarpov15/kareem/commit/6dd8531)), closes [Automattic/mongoose#3232](https://github.com/Automattic/mongoose/issues/3232)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
<a name="1.5.0"></a>
|
|
173
|
+
## 1.5.0 (2017-07-20)
|
|
174
|
+
|
|
175
|
+
* chore: release 1.5.0 ([9c491a0](https://github.com/vkarpov15/kareem/commit/9c491a0))
|
|
176
|
+
* fix: improve post error handlers results ([9928dd5](https://github.com/vkarpov15/kareem/commit/9928dd5)), closes [Automattic/mongoose#5466](https://github.com/Automattic/mongoose/issues/5466)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
<a name="1.4.2"></a>
|
|
181
|
+
## <small>1.4.2 (2017-07-06)</small>
|
|
182
|
+
|
|
183
|
+
* chore: release 1.4.2 ([8d14ac5](https://github.com/vkarpov15/kareem/commit/8d14ac5))
|
|
184
|
+
* fix: correct args re: Automattic/mongoose#5405 ([3f28ae6](https://github.com/vkarpov15/kareem/commit/3f28ae6)), closes [Automattic/mongoose#5405](https://github.com/Automattic/mongoose/issues/5405)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<a name="1.4.1"></a>
|
|
189
|
+
## <small>1.4.1 (2017-04-25)</small>
|
|
190
|
+
|
|
191
|
+
* chore: release 1.4.1 ([5ecf0c2](https://github.com/vkarpov15/kareem/commit/5ecf0c2))
|
|
192
|
+
* fix: handle numAsyncPres with clone() ([c72e857](https://github.com/vkarpov15/kareem/commit/c72e857)), closes [#8](https://github.com/vkarpov15/kareem/issues/8)
|
|
193
|
+
* test: repro #8 ([9b4d6b2](https://github.com/vkarpov15/kareem/commit/9b4d6b2)), closes [#8](https://github.com/vkarpov15/kareem/issues/8)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
<a name="1.4.0"></a>
|
|
198
|
+
## 1.4.0 (2017-04-19)
|
|
199
|
+
|
|
200
|
+
* chore: release 1.4.0 ([101c5f5](https://github.com/vkarpov15/kareem/commit/101c5f5))
|
|
201
|
+
* feat: add merge() function ([285325e](https://github.com/vkarpov15/kareem/commit/285325e))
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
<a name="1.3.0"></a>
|
|
206
|
+
## 1.3.0 (2017-03-26)
|
|
207
|
+
|
|
208
|
+
* chore: release 1.3.0 ([f3a9e50](https://github.com/vkarpov15/kareem/commit/f3a9e50))
|
|
209
|
+
* feat: pass function args to execPre ([4dd466d](https://github.com/vkarpov15/kareem/commit/4dd466d))
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
<a name="1.2.1"></a>
|
|
214
|
+
## <small>1.2.1 (2017-02-03)</small>
|
|
215
|
+
|
|
216
|
+
* chore: release 1.2.1 ([d97081f](https://github.com/vkarpov15/kareem/commit/d97081f))
|
|
217
|
+
* fix: filter out _kareemIgnored args for error handlers re: Automattic/mongoose#4925 ([ddc7aeb](https://github.com/vkarpov15/kareem/commit/ddc7aeb)), closes [Automattic/mongoose#4925](https://github.com/Automattic/mongoose/issues/4925)
|
|
218
|
+
* fix: make error handlers handle errors in pre hooks ([af38033](https://github.com/vkarpov15/kareem/commit/af38033)), closes [Automattic/mongoose#4927](https://github.com/Automattic/mongoose/issues/4927)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
<a name="1.2.0"></a>
|
|
223
|
+
## 1.2.0 (2017-01-02)
|
|
224
|
+
|
|
225
|
+
* chore: release 1.2.0 ([033225c](https://github.com/vkarpov15/kareem/commit/033225c))
|
|
226
|
+
* chore: upgrade deps ([f9e9a09](https://github.com/vkarpov15/kareem/commit/f9e9a09))
|
|
227
|
+
* feat: add _kareemIgnore re: Automattic/mongoose#4836 ([7957771](https://github.com/vkarpov15/kareem/commit/7957771)), closes [Automattic/mongoose#4836](https://github.com/Automattic/mongoose/issues/4836)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<a name="1.1.5"></a>
|
|
232
|
+
## <small>1.1.5 (2016-12-13)</small>
|
|
233
|
+
|
|
234
|
+
* chore: release 1.1.5 ([1a9f684](https://github.com/vkarpov15/kareem/commit/1a9f684))
|
|
235
|
+
* fix: correct field name ([04a0e9d](https://github.com/vkarpov15/kareem/commit/04a0e9d))
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
<a name="1.1.4"></a>
|
|
240
|
+
## <small>1.1.4 (2016-12-09)</small>
|
|
241
|
+
|
|
242
|
+
* chore: release 1.1.4 ([ece401c](https://github.com/vkarpov15/kareem/commit/ece401c))
|
|
243
|
+
* chore: run tests on node 6 ([e0cb1cb](https://github.com/vkarpov15/kareem/commit/e0cb1cb))
|
|
244
|
+
* fix: only copy own properties in clone() ([dfe28ce](https://github.com/vkarpov15/kareem/commit/dfe28ce)), closes [#7](https://github.com/vkarpov15/kareem/issues/7)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<a name="1.1.3"></a>
|
|
249
|
+
## <small>1.1.3 (2016-06-27)</small>
|
|
250
|
+
|
|
251
|
+
* chore: release 1.1.3 ([87171c8](https://github.com/vkarpov15/kareem/commit/87171c8))
|
|
252
|
+
* fix: couple more issues with arg processing ([c65f523](https://github.com/vkarpov15/kareem/commit/c65f523))
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
<a name="1.1.2"></a>
|
|
257
|
+
## <small>1.1.2 (2016-06-27)</small>
|
|
258
|
+
|
|
259
|
+
* chore: release 1.1.2 ([8e102b6](https://github.com/vkarpov15/kareem/commit/8e102b6))
|
|
260
|
+
* fix: add early return ([4feda4e](https://github.com/vkarpov15/kareem/commit/4feda4e))
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
<a name="1.1.1"></a>
|
|
265
|
+
## <small>1.1.1 (2016-06-27)</small>
|
|
266
|
+
|
|
267
|
+
* chore: release 1.1.1 ([8bb3050](https://github.com/vkarpov15/kareem/commit/8bb3050))
|
|
268
|
+
* fix: skip error handlers if no error ([0eb3a44](https://github.com/vkarpov15/kareem/commit/0eb3a44))
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
<a name="1.1.0"></a>
|
|
273
|
+
## 1.1.0 (2016-05-11)
|
|
274
|
+
|
|
275
|
+
* chore: release 1.1.0 ([85332d9](https://github.com/vkarpov15/kareem/commit/85332d9))
|
|
276
|
+
* chore: test on node 4 and node 5 ([1faefa1](https://github.com/vkarpov15/kareem/commit/1faefa1))
|
|
277
|
+
* 100% coverage again ([c9aee4e](https://github.com/vkarpov15/kareem/commit/c9aee4e))
|
|
278
|
+
* add support for error post hooks ([d378113](https://github.com/vkarpov15/kareem/commit/d378113))
|
|
279
|
+
* basic setup for sync hooks #4 ([55aa081](https://github.com/vkarpov15/kareem/commit/55aa081)), closes [#4](https://github.com/vkarpov15/kareem/issues/4)
|
|
280
|
+
* proof of concept for error handlers ([e4a07d9](https://github.com/vkarpov15/kareem/commit/e4a07d9))
|
|
281
|
+
* refactor out handleWrapError helper ([b19af38](https://github.com/vkarpov15/kareem/commit/b19af38))
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
<a name="1.0.1"></a>
|
|
286
|
+
## <small>1.0.1 (2015-05-10)</small>
|
|
287
|
+
|
|
288
|
+
* Fix #1 ([de60dc6](https://github.com/vkarpov15/kareem/commit/de60dc6)), closes [#1](https://github.com/vkarpov15/kareem/issues/1)
|
|
289
|
+
* release 1.0.1 ([6971088](https://github.com/vkarpov15/kareem/commit/6971088))
|
|
290
|
+
* Run tests on iojs in travis ([adcd201](https://github.com/vkarpov15/kareem/commit/adcd201))
|
|
291
|
+
* support legacy post hook behavior in wrap() ([23fa74c](https://github.com/vkarpov15/kareem/commit/23fa74c))
|
|
292
|
+
* Use node 0.12 in travis ([834689d](https://github.com/vkarpov15/kareem/commit/834689d))
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
<a name="1.0.0"></a>
|
|
297
|
+
## 1.0.0 (2015-01-28)
|
|
298
|
+
|
|
299
|
+
* Tag 1.0.0 ([4c5a35a](https://github.com/vkarpov15/kareem/commit/4c5a35a))
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
<a name="0.0.8"></a>
|
|
304
|
+
## <small>0.0.8 (2015-01-27)</small>
|
|
305
|
+
|
|
306
|
+
* Add clone function ([688bba7](https://github.com/vkarpov15/kareem/commit/688bba7))
|
|
307
|
+
* Add jscs for style checking ([5c93149](https://github.com/vkarpov15/kareem/commit/5c93149))
|
|
308
|
+
* Bump 0.0.8 ([03c0d2f](https://github.com/vkarpov15/kareem/commit/03c0d2f))
|
|
309
|
+
* Fix jscs config, add gulp rules ([9989abf](https://github.com/vkarpov15/kareem/commit/9989abf))
|
|
310
|
+
* fix Makefile typo ([1f7e61a](https://github.com/vkarpov15/kareem/commit/1f7e61a))
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
<a name="0.0.7"></a>
|
|
315
|
+
## <small>0.0.7 (2015-01-04)</small>
|
|
316
|
+
|
|
317
|
+
* Bump 0.0.7 ([98ef173](https://github.com/vkarpov15/kareem/commit/98ef173))
|
|
318
|
+
* fix LearnBoost/mongoose#2553 - use null instead of undefined for err ([9157b48](https://github.com/vkarpov15/kareem/commit/9157b48)), closes [LearnBoost/mongoose#2553](https://github.com/LearnBoost/mongoose/issues/2553)
|
|
319
|
+
* Regenerate docs ([2331cdf](https://github.com/vkarpov15/kareem/commit/2331cdf))
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
<a name="0.0.6"></a>
|
|
324
|
+
## <small>0.0.6 (2015-01-01)</small>
|
|
325
|
+
|
|
326
|
+
* Update docs and bump 0.0.6 ([92c12a7](https://github.com/vkarpov15/kareem/commit/92c12a7))
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
<a name="0.0.5"></a>
|
|
331
|
+
## <small>0.0.5 (2015-01-01)</small>
|
|
332
|
+
|
|
333
|
+
* Add coverage rule to Makefile ([825a91c](https://github.com/vkarpov15/kareem/commit/825a91c))
|
|
334
|
+
* Add coveralls to README ([fb52369](https://github.com/vkarpov15/kareem/commit/fb52369))
|
|
335
|
+
* Add coveralls to travis ([93f6f15](https://github.com/vkarpov15/kareem/commit/93f6f15))
|
|
336
|
+
* Add createWrapper() function ([ea77741](https://github.com/vkarpov15/kareem/commit/ea77741))
|
|
337
|
+
* Add istanbul code coverage ([6eceeef](https://github.com/vkarpov15/kareem/commit/6eceeef))
|
|
338
|
+
* Add some more comments for examples ([c5b0c6f](https://github.com/vkarpov15/kareem/commit/c5b0c6f))
|
|
339
|
+
* Add travis ([e6dcb06](https://github.com/vkarpov15/kareem/commit/e6dcb06))
|
|
340
|
+
* Add travis badge to docs ([ad8c9b3](https://github.com/vkarpov15/kareem/commit/ad8c9b3))
|
|
341
|
+
* Add wrap() tests, 100% coverage ([6945be4](https://github.com/vkarpov15/kareem/commit/6945be4))
|
|
342
|
+
* Better test coverage for execPost ([d9ad539](https://github.com/vkarpov15/kareem/commit/d9ad539))
|
|
343
|
+
* Bump 0.0.5 ([69875b1](https://github.com/vkarpov15/kareem/commit/69875b1))
|
|
344
|
+
* Docs fix ([15b7098](https://github.com/vkarpov15/kareem/commit/15b7098))
|
|
345
|
+
* Fix silly mistake in docs generation ([50373eb](https://github.com/vkarpov15/kareem/commit/50373eb))
|
|
346
|
+
* Fix typo in readme ([fec4925](https://github.com/vkarpov15/kareem/commit/fec4925))
|
|
347
|
+
* Linkify travis badge ([92b25fe](https://github.com/vkarpov15/kareem/commit/92b25fe))
|
|
348
|
+
* Make travis run coverage ([747157b](https://github.com/vkarpov15/kareem/commit/747157b))
|
|
349
|
+
* Move travis status badge ([d52e89b](https://github.com/vkarpov15/kareem/commit/d52e89b))
|
|
350
|
+
* Quick fix for coverage ([50bbddb](https://github.com/vkarpov15/kareem/commit/50bbddb))
|
|
351
|
+
* Typo fix ([adea794](https://github.com/vkarpov15/kareem/commit/adea794))
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
<a name="0.0.4"></a>
|
|
356
|
+
## <small>0.0.4 (2014-12-13)</small>
|
|
357
|
+
|
|
358
|
+
* Bump 0.0.4, run docs generation ([51a15fe](https://github.com/vkarpov15/kareem/commit/51a15fe))
|
|
359
|
+
* Use correct post parameters in wrap() ([9bb5da3](https://github.com/vkarpov15/kareem/commit/9bb5da3))
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
<a name="0.0.3"></a>
|
|
364
|
+
## <small>0.0.3 (2014-12-12)</small>
|
|
365
|
+
|
|
366
|
+
* Add npm test script, fix small bug with args not getting passed through post ([49e3e68](https://github.com/vkarpov15/kareem/commit/49e3e68))
|
|
367
|
+
* Bump 0.0.3 ([65621d8](https://github.com/vkarpov15/kareem/commit/65621d8))
|
|
368
|
+
* Update readme ([901388b](https://github.com/vkarpov15/kareem/commit/901388b))
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
<a name="0.0.2"></a>
|
|
373
|
+
## <small>0.0.2 (2014-12-12)</small>
|
|
374
|
+
|
|
375
|
+
* Add github repo and bump 0.0.2 ([59db8be](https://github.com/vkarpov15/kareem/commit/59db8be))
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
<a name="0.0.1"></a>
|
|
380
|
+
## <small>0.0.1 (2014-12-12)</small>
|
|
381
|
+
|
|
382
|
+
* Add basic docs ([ad29ea4](https://github.com/vkarpov15/kareem/commit/ad29ea4))
|
|
383
|
+
* Add pre hooks ([2ffc356](https://github.com/vkarpov15/kareem/commit/2ffc356))
|
|
384
|
+
* Add wrap function ([68c540c](https://github.com/vkarpov15/kareem/commit/68c540c))
|
|
385
|
+
* Bump to version 0.0.1 ([a4bfd68](https://github.com/vkarpov15/kareem/commit/a4bfd68))
|
|
386
|
+
* Initial commit ([4002458](https://github.com/vkarpov15/kareem/commit/4002458))
|
|
387
|
+
* Initial deposit ([98fc489](https://github.com/vkarpov15/kareem/commit/98fc489))
|
|
388
|
+
* Post hooks ([395b67c](https://github.com/vkarpov15/kareem/commit/395b67c))
|
|
389
|
+
* Some basic setup work ([82df75e](https://github.com/vkarpov15/kareem/commit/82df75e))
|
|
390
|
+
* Support sync pre hooks ([1cc1b9f](https://github.com/vkarpov15/kareem/commit/1cc1b9f))
|
|
391
|
+
* Update package.json description ([978da18](https://github.com/vkarpov15/kareem/commit/978da18))
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
<a name="2.2.5"></a>
|
|
396
|
+
## <small>2.2.5 (2018-09-24)</small>
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
<a name="2.2.4"></a>
|
|
402
|
+
## <small>2.2.4 (2018-09-24)</small>
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
<a name="2.2.3"></a>
|
|
408
|
+
## <small>2.2.3 (2018-09-24)</small>
|
|
409
|
+
|
|
410
|
+
* fix(filter): copy async pres correctly with `filter()` ([1b1ed8a](https://github.com/vkarpov15/kareem/commit/1b1ed8a)), closes [Automattic/mongoose#3054](https://github.com/Automattic/mongoose/issues/3054)
|
|
411
|
+
* feat: add filter() function ([1f641f4](https://github.com/vkarpov15/kareem/commit/1f641f4))
|
|
412
|
+
* feat: support storing options on pre and post hooks ([59220b9](https://github.com/vkarpov15/kareem/commit/59220b9))
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
<a name="2.2.3"></a>
|
|
417
|
+
## <small>2.2.3 (2018-09-10)</small>
|
|
418
|
+
|
|
419
|
+
* chore: release 2.2.3 ([af653a3](https://github.com/vkarpov15/kareem/commit/af653a3))
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
<a name="2.2.2"></a>
|
|
424
|
+
## <small>2.2.2 (2018-09-10)</small>
|
|
425
|
+
|
|
426
|
+
* chore: release 2.2.2 ([3f0144d](https://github.com/vkarpov15/kareem/commit/3f0144d))
|
|
427
|
+
* fix: allow merge() to not clone ([e628d65](https://github.com/vkarpov15/kareem/commit/e628d65))
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
<a name="2.2.1"></a>
|
|
432
|
+
## <small>2.2.1 (2018-06-05)</small>
|
|
433
|
+
|
|
434
|
+
* chore: release 2.2.1 ([4625a64](https://github.com/vkarpov15/kareem/commit/4625a64))
|
|
435
|
+
* chore: remove lockfile from git ([7f3e4e6](https://github.com/vkarpov15/kareem/commit/7f3e4e6))
|
|
436
|
+
* fix: handle numAsync correctly when merging ([fef8e7e](https://github.com/vkarpov15/kareem/commit/fef8e7e))
|
|
437
|
+
* test: repro issue with not copying numAsync ([952d9db](https://github.com/vkarpov15/kareem/commit/952d9db))
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
<a name="2.2.0"></a>
|
|
442
|
+
## 2.2.0 (2018-06-05)
|
|
443
|
+
|
|
444
|
+
* chore: release 2.2.0 ([ff9ad03](https://github.com/vkarpov15/kareem/commit/ff9ad03))
|
|
445
|
+
* fix: use maps instead of objects for _pres and _posts so `toString()` doesn't get reported as having ([55df303](https://github.com/vkarpov15/kareem/commit/55df303)), closes [Automattic/mongoose#6538](https://github.com/Automattic/mongoose/issues/6538)
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
<a name="2.1.0"></a>
|
|
450
|
+
## 2.1.0 (2018-05-16)
|
|
451
|
+
|
|
452
|
+
* chore: release 2.1.0 ([ba5f1bc](https://github.com/vkarpov15/kareem/commit/ba5f1bc))
|
|
453
|
+
* feat: add option to check wrapped function return value for promises ([c9d7dd1](https://github.com/vkarpov15/kareem/commit/c9d7dd1))
|
|
454
|
+
* refactor: use const in wrap() ([0fc21f9](https://github.com/vkarpov15/kareem/commit/0fc21f9))
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
<a name="2.0.7"></a>
|
|
459
|
+
## <small>2.0.7 (2018-04-28)</small>
|
|
460
|
+
|
|
461
|
+
* chore: release 2.0.7 ([0bf91e6](https://github.com/vkarpov15/kareem/commit/0bf91e6))
|
|
462
|
+
* feat: add `hasHooks()` ([225f18d](https://github.com/vkarpov15/kareem/commit/225f18d)), closes [Automattic/mongoose#6385](https://github.com/Automattic/mongoose/issues/6385)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
<a name="2.0.6"></a>
|
|
467
|
+
## <small>2.0.6 (2018-03-22)</small>
|
|
468
|
+
|
|
469
|
+
* chore: release 2.0.6 ([f3d406b](https://github.com/vkarpov15/kareem/commit/f3d406b))
|
|
470
|
+
* fix(wrap): ensure fast path still wraps function in `nextTick()` for chaining ([7000494](https://github.com/vkarpov15/kareem/commit/7000494)), closes [Automattic/mongoose#6250](https://github.com/Automattic/mongoose/issues/6250) [dsanel/mongoose-delete#36](https://github.com/dsanel/mongoose-delete/issues/36)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
<a name="2.0.5"></a>
|
|
475
|
+
## <small>2.0.5 (2018-02-22)</small>
|
|
476
|
+
|
|
477
|
+
* chore: release 2.0.5 ([3286612](https://github.com/vkarpov15/kareem/commit/3286612))
|
|
478
|
+
* perf(createWrapper): don't create wrapper if there are no hooks ([5afc5b9](https://github.com/vkarpov15/kareem/commit/5afc5b9)), closes [Automattic/mongoose#6126](https://github.com/Automattic/mongoose/issues/6126)
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
<a name="2.0.4"></a>
|
|
483
|
+
## <small>2.0.4 (2018-02-08)</small>
|
|
484
|
+
|
|
485
|
+
* chore: release 2.0.4 ([2ab0293](https://github.com/vkarpov15/kareem/commit/2ab0293))
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
<a name="2.0.3"></a>
|
|
490
|
+
## <small>2.0.3 (2018-02-01)</small>
|
|
491
|
+
|
|
492
|
+
* chore: release 2.0.3 ([3c1abe5](https://github.com/vkarpov15/kareem/commit/3c1abe5))
|
|
493
|
+
* fix: use process.nextTick() re: Automattic/mongoose#6074 ([e5bfe33](https://github.com/vkarpov15/kareem/commit/e5bfe33)), closes [Automattic/mongoose#6074](https://github.com/Automattic/mongoose/issues/6074)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
<a name="2.0.2"></a>
|
|
498
|
+
## <small>2.0.2 (2018-01-24)</small>
|
|
499
|
+
|
|
500
|
+
* chore: fix license ([a9d755c](https://github.com/vkarpov15/kareem/commit/a9d755c)), closes [#10](https://github.com/vkarpov15/kareem/issues/10)
|
|
501
|
+
* chore: release 2.0.2 ([fe87ab6](https://github.com/vkarpov15/kareem/commit/fe87ab6))
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
<a name="2.0.1"></a>
|
|
506
|
+
## <small>2.0.1 (2018-01-09)</small>
|
|
507
|
+
|
|
508
|
+
* chore: release 2.0.1 with lockfile bump ([09c44fb](https://github.com/vkarpov15/kareem/commit/09c44fb))
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
<a name="2.0.0"></a>
|
|
513
|
+
## 2.0.0 (2018-01-09)
|
|
514
|
+
|
|
515
|
+
* chore: bump marked re: security ([cc564a9](https://github.com/vkarpov15/kareem/commit/cc564a9))
|
|
516
|
+
* chore: release 2.0.0 ([f511d1c](https://github.com/vkarpov15/kareem/commit/f511d1c))
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
<a name="2.0.0-rc5"></a>
|
|
521
|
+
## 2.0.0-rc5 (2017-12-23)
|
|
522
|
+
|
|
523
|
+
* chore: fix build on node 4+5 ([6dac5a4](https://github.com/vkarpov15/kareem/commit/6dac5a4))
|
|
524
|
+
* chore: fix built on node 4 + 5 again ([434ef0a](https://github.com/vkarpov15/kareem/commit/434ef0a))
|
|
525
|
+
* chore: release 2.0.0-rc5 ([25a32ee](https://github.com/vkarpov15/kareem/commit/25a32ee))
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
<a name="2.0.0-rc4"></a>
|
|
530
|
+
## 2.0.0-rc4 (2017-12-22)
|
|
531
|
+
|
|
532
|
+
* chore: release 2.0.0-rc4 ([49fc083](https://github.com/vkarpov15/kareem/commit/49fc083))
|
|
533
|
+
* BREAKING CHANGE: deduplicate when merging hooks re: Automattic/mongoose#2945 ([d458573](https://github.com/vkarpov15/kareem/commit/d458573)), closes [Automattic/mongoose#2945](https://github.com/Automattic/mongoose/issues/2945)
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
<a name="2.0.0-rc3"></a>
|
|
538
|
+
## 2.0.0-rc3 (2017-12-22)
|
|
539
|
+
|
|
540
|
+
* chore: release 2.0.0-rc3 ([adaaa00](https://github.com/vkarpov15/kareem/commit/adaaa00))
|
|
541
|
+
* feat: support returning promises from middleware functions ([05b4480](https://github.com/vkarpov15/kareem/commit/05b4480)), closes [Automattic/mongoose#3779](https://github.com/Automattic/mongoose/issues/3779)
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
<a name="2.0.0-rc2"></a>
|
|
546
|
+
## 2.0.0-rc2 (2017-12-21)
|
|
547
|
+
|
|
548
|
+
* chore: release 2.0.0-rc2 ([76325fa](https://github.com/vkarpov15/kareem/commit/76325fa))
|
|
549
|
+
* fix: ensure next() and done() run in next tick ([6c20684](https://github.com/vkarpov15/kareem/commit/6c20684))
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
<a name="2.0.0-rc1"></a>
|
|
554
|
+
## 2.0.0-rc1 (2017-12-21)
|
|
555
|
+
|
|
556
|
+
* chore: improve test coverage re: Automattic/mongoose#3232 ([7b45cf0](https://github.com/vkarpov15/kareem/commit/7b45cf0)), closes [Automattic/mongoose#3232](https://github.com/Automattic/mongoose/issues/3232)
|
|
557
|
+
* chore: release 2.0.0-rc1 ([9b83f52](https://github.com/vkarpov15/kareem/commit/9b83f52))
|
|
558
|
+
* BREAKING CHANGE: report sync exceptions as errors, only allow calling next() and done() once ([674adcc](https://github.com/vkarpov15/kareem/commit/674adcc)), closes [Automattic/mongoose#3483](https://github.com/Automattic/mongoose/issues/3483)
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
<a name="2.0.0-rc0"></a>
|
|
563
|
+
## 2.0.0-rc0 (2017-12-17)
|
|
564
|
+
|
|
565
|
+
* chore: release 2.0.0-rc0 ([16b44b5](https://github.com/vkarpov15/kareem/commit/16b44b5))
|
|
566
|
+
* BREAKING CHANGE: drop support for node < 4 ([9cbb8c7](https://github.com/vkarpov15/kareem/commit/9cbb8c7))
|
|
567
|
+
* BREAKING CHANGE: remove useLegacyPost and add several new features ([6dd8531](https://github.com/vkarpov15/kareem/commit/6dd8531)), closes [Automattic/mongoose#3232](https://github.com/Automattic/mongoose/issues/3232)
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
<a name="1.5.0"></a>
|
|
572
|
+
## 1.5.0 (2017-07-20)
|
|
573
|
+
|
|
574
|
+
* chore: release 1.5.0 ([9c491a0](https://github.com/vkarpov15/kareem/commit/9c491a0))
|
|
575
|
+
* fix: improve post error handlers results ([9928dd5](https://github.com/vkarpov15/kareem/commit/9928dd5)), closes [Automattic/mongoose#5466](https://github.com/Automattic/mongoose/issues/5466)
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
<a name="1.4.2"></a>
|
|
580
|
+
## <small>1.4.2 (2017-07-06)</small>
|
|
581
|
+
|
|
582
|
+
* chore: release 1.4.2 ([8d14ac5](https://github.com/vkarpov15/kareem/commit/8d14ac5))
|
|
583
|
+
* fix: correct args re: Automattic/mongoose#5405 ([3f28ae6](https://github.com/vkarpov15/kareem/commit/3f28ae6)), closes [Automattic/mongoose#5405](https://github.com/Automattic/mongoose/issues/5405)
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
<a name="1.4.1"></a>
|
|
588
|
+
## <small>1.4.1 (2017-04-25)</small>
|
|
589
|
+
|
|
590
|
+
* chore: release 1.4.1 ([5ecf0c2](https://github.com/vkarpov15/kareem/commit/5ecf0c2))
|
|
591
|
+
* fix: handle numAsyncPres with clone() ([c72e857](https://github.com/vkarpov15/kareem/commit/c72e857)), closes [#8](https://github.com/vkarpov15/kareem/issues/8)
|
|
592
|
+
* test: repro #8 ([9b4d6b2](https://github.com/vkarpov15/kareem/commit/9b4d6b2)), closes [#8](https://github.com/vkarpov15/kareem/issues/8)
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
<a name="1.4.0"></a>
|
|
597
|
+
## 1.4.0 (2017-04-19)
|
|
598
|
+
|
|
599
|
+
* chore: release 1.4.0 ([101c5f5](https://github.com/vkarpov15/kareem/commit/101c5f5))
|
|
600
|
+
* feat: add merge() function ([285325e](https://github.com/vkarpov15/kareem/commit/285325e))
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
<a name="1.3.0"></a>
|
|
605
|
+
## 1.3.0 (2017-03-26)
|
|
606
|
+
|
|
607
|
+
* chore: release 1.3.0 ([f3a9e50](https://github.com/vkarpov15/kareem/commit/f3a9e50))
|
|
608
|
+
* feat: pass function args to execPre ([4dd466d](https://github.com/vkarpov15/kareem/commit/4dd466d))
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
<a name="1.2.1"></a>
|
|
613
|
+
## <small>1.2.1 (2017-02-03)</small>
|
|
614
|
+
|
|
615
|
+
* chore: release 1.2.1 ([d97081f](https://github.com/vkarpov15/kareem/commit/d97081f))
|
|
616
|
+
* fix: filter out _kareemIgnored args for error handlers re: Automattic/mongoose#4925 ([ddc7aeb](https://github.com/vkarpov15/kareem/commit/ddc7aeb)), closes [Automattic/mongoose#4925](https://github.com/Automattic/mongoose/issues/4925)
|
|
617
|
+
* fix: make error handlers handle errors in pre hooks ([af38033](https://github.com/vkarpov15/kareem/commit/af38033)), closes [Automattic/mongoose#4927](https://github.com/Automattic/mongoose/issues/4927)
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
<a name="1.2.0"></a>
|
|
622
|
+
## 1.2.0 (2017-01-02)
|
|
623
|
+
|
|
624
|
+
* chore: release 1.2.0 ([033225c](https://github.com/vkarpov15/kareem/commit/033225c))
|
|
625
|
+
* chore: upgrade deps ([f9e9a09](https://github.com/vkarpov15/kareem/commit/f9e9a09))
|
|
626
|
+
* feat: add _kareemIgnore re: Automattic/mongoose#4836 ([7957771](https://github.com/vkarpov15/kareem/commit/7957771)), closes [Automattic/mongoose#4836](https://github.com/Automattic/mongoose/issues/4836)
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
<a name="1.1.5"></a>
|
|
631
|
+
## <small>1.1.5 (2016-12-13)</small>
|
|
632
|
+
|
|
633
|
+
* chore: release 1.1.5 ([1a9f684](https://github.com/vkarpov15/kareem/commit/1a9f684))
|
|
634
|
+
* fix: correct field name ([04a0e9d](https://github.com/vkarpov15/kareem/commit/04a0e9d))
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
<a name="1.1.4"></a>
|
|
639
|
+
## <small>1.1.4 (2016-12-09)</small>
|
|
640
|
+
|
|
641
|
+
* chore: release 1.1.4 ([ece401c](https://github.com/vkarpov15/kareem/commit/ece401c))
|
|
642
|
+
* chore: run tests on node 6 ([e0cb1cb](https://github.com/vkarpov15/kareem/commit/e0cb1cb))
|
|
643
|
+
* fix: only copy own properties in clone() ([dfe28ce](https://github.com/vkarpov15/kareem/commit/dfe28ce)), closes [#7](https://github.com/vkarpov15/kareem/issues/7)
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
<a name="1.1.3"></a>
|
|
648
|
+
## <small>1.1.3 (2016-06-27)</small>
|
|
649
|
+
|
|
650
|
+
* chore: release 1.1.3 ([87171c8](https://github.com/vkarpov15/kareem/commit/87171c8))
|
|
651
|
+
* fix: couple more issues with arg processing ([c65f523](https://github.com/vkarpov15/kareem/commit/c65f523))
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
<a name="1.1.2"></a>
|
|
656
|
+
## <small>1.1.2 (2016-06-27)</small>
|
|
657
|
+
|
|
658
|
+
* chore: release 1.1.2 ([8e102b6](https://github.com/vkarpov15/kareem/commit/8e102b6))
|
|
659
|
+
* fix: add early return ([4feda4e](https://github.com/vkarpov15/kareem/commit/4feda4e))
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
<a name="1.1.1"></a>
|
|
664
|
+
## <small>1.1.1 (2016-06-27)</small>
|
|
665
|
+
|
|
666
|
+
* chore: release 1.1.1 ([8bb3050](https://github.com/vkarpov15/kareem/commit/8bb3050))
|
|
667
|
+
* fix: skip error handlers if no error ([0eb3a44](https://github.com/vkarpov15/kareem/commit/0eb3a44))
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
<a name="1.1.0"></a>
|
|
672
|
+
## 1.1.0 (2016-05-11)
|
|
673
|
+
|
|
674
|
+
* chore: release 1.1.0 ([85332d9](https://github.com/vkarpov15/kareem/commit/85332d9))
|
|
675
|
+
* chore: test on node 4 and node 5 ([1faefa1](https://github.com/vkarpov15/kareem/commit/1faefa1))
|
|
676
|
+
* 100% coverage again ([c9aee4e](https://github.com/vkarpov15/kareem/commit/c9aee4e))
|
|
677
|
+
* add support for error post hooks ([d378113](https://github.com/vkarpov15/kareem/commit/d378113))
|
|
678
|
+
* basic setup for sync hooks #4 ([55aa081](https://github.com/vkarpov15/kareem/commit/55aa081)), closes [#4](https://github.com/vkarpov15/kareem/issues/4)
|
|
679
|
+
* proof of concept for error handlers ([e4a07d9](https://github.com/vkarpov15/kareem/commit/e4a07d9))
|
|
680
|
+
* refactor out handleWrapError helper ([b19af38](https://github.com/vkarpov15/kareem/commit/b19af38))
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
<a name="1.0.1"></a>
|
|
685
|
+
## <small>1.0.1 (2015-05-10)</small>
|
|
686
|
+
|
|
687
|
+
* Fix #1 ([de60dc6](https://github.com/vkarpov15/kareem/commit/de60dc6)), closes [#1](https://github.com/vkarpov15/kareem/issues/1)
|
|
688
|
+
* release 1.0.1 ([6971088](https://github.com/vkarpov15/kareem/commit/6971088))
|
|
689
|
+
* Run tests on iojs in travis ([adcd201](https://github.com/vkarpov15/kareem/commit/adcd201))
|
|
690
|
+
* support legacy post hook behavior in wrap() ([23fa74c](https://github.com/vkarpov15/kareem/commit/23fa74c))
|
|
691
|
+
* Use node 0.12 in travis ([834689d](https://github.com/vkarpov15/kareem/commit/834689d))
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
<a name="1.0.0"></a>
|
|
696
|
+
## 1.0.0 (2015-01-28)
|
|
697
|
+
|
|
698
|
+
* Tag 1.0.0 ([4c5a35a](https://github.com/vkarpov15/kareem/commit/4c5a35a))
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
<a name="0.0.8"></a>
|
|
703
|
+
## <small>0.0.8 (2015-01-27)</small>
|
|
704
|
+
|
|
705
|
+
* Add clone function ([688bba7](https://github.com/vkarpov15/kareem/commit/688bba7))
|
|
706
|
+
* Add jscs for style checking ([5c93149](https://github.com/vkarpov15/kareem/commit/5c93149))
|
|
707
|
+
* Bump 0.0.8 ([03c0d2f](https://github.com/vkarpov15/kareem/commit/03c0d2f))
|
|
708
|
+
* Fix jscs config, add gulp rules ([9989abf](https://github.com/vkarpov15/kareem/commit/9989abf))
|
|
709
|
+
* fix Makefile typo ([1f7e61a](https://github.com/vkarpov15/kareem/commit/1f7e61a))
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
<a name="0.0.7"></a>
|
|
714
|
+
## <small>0.0.7 (2015-01-04)</small>
|
|
715
|
+
|
|
716
|
+
* Bump 0.0.7 ([98ef173](https://github.com/vkarpov15/kareem/commit/98ef173))
|
|
717
|
+
* fix LearnBoost/mongoose#2553 - use null instead of undefined for err ([9157b48](https://github.com/vkarpov15/kareem/commit/9157b48)), closes [LearnBoost/mongoose#2553](https://github.com/LearnBoost/mongoose/issues/2553)
|
|
718
|
+
* Regenerate docs ([2331cdf](https://github.com/vkarpov15/kareem/commit/2331cdf))
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
<a name="0.0.6"></a>
|
|
723
|
+
## <small>0.0.6 (2015-01-01)</small>
|
|
724
|
+
|
|
725
|
+
* Update docs and bump 0.0.6 ([92c12a7](https://github.com/vkarpov15/kareem/commit/92c12a7))
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
<a name="0.0.5"></a>
|
|
730
|
+
## <small>0.0.5 (2015-01-01)</small>
|
|
731
|
+
|
|
732
|
+
* Add coverage rule to Makefile ([825a91c](https://github.com/vkarpov15/kareem/commit/825a91c))
|
|
733
|
+
* Add coveralls to README ([fb52369](https://github.com/vkarpov15/kareem/commit/fb52369))
|
|
734
|
+
* Add coveralls to travis ([93f6f15](https://github.com/vkarpov15/kareem/commit/93f6f15))
|
|
735
|
+
* Add createWrapper() function ([ea77741](https://github.com/vkarpov15/kareem/commit/ea77741))
|
|
736
|
+
* Add istanbul code coverage ([6eceeef](https://github.com/vkarpov15/kareem/commit/6eceeef))
|
|
737
|
+
* Add some more comments for examples ([c5b0c6f](https://github.com/vkarpov15/kareem/commit/c5b0c6f))
|
|
738
|
+
* Add travis ([e6dcb06](https://github.com/vkarpov15/kareem/commit/e6dcb06))
|
|
739
|
+
* Add travis badge to docs ([ad8c9b3](https://github.com/vkarpov15/kareem/commit/ad8c9b3))
|
|
740
|
+
* Add wrap() tests, 100% coverage ([6945be4](https://github.com/vkarpov15/kareem/commit/6945be4))
|
|
741
|
+
* Better test coverage for execPost ([d9ad539](https://github.com/vkarpov15/kareem/commit/d9ad539))
|
|
742
|
+
* Bump 0.0.5 ([69875b1](https://github.com/vkarpov15/kareem/commit/69875b1))
|
|
743
|
+
* Docs fix ([15b7098](https://github.com/vkarpov15/kareem/commit/15b7098))
|
|
744
|
+
* Fix silly mistake in docs generation ([50373eb](https://github.com/vkarpov15/kareem/commit/50373eb))
|
|
745
|
+
* Fix typo in readme ([fec4925](https://github.com/vkarpov15/kareem/commit/fec4925))
|
|
746
|
+
* Linkify travis badge ([92b25fe](https://github.com/vkarpov15/kareem/commit/92b25fe))
|
|
747
|
+
* Make travis run coverage ([747157b](https://github.com/vkarpov15/kareem/commit/747157b))
|
|
748
|
+
* Move travis status badge ([d52e89b](https://github.com/vkarpov15/kareem/commit/d52e89b))
|
|
749
|
+
* Quick fix for coverage ([50bbddb](https://github.com/vkarpov15/kareem/commit/50bbddb))
|
|
750
|
+
* Typo fix ([adea794](https://github.com/vkarpov15/kareem/commit/adea794))
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
<a name="0.0.4"></a>
|
|
755
|
+
## <small>0.0.4 (2014-12-13)</small>
|
|
756
|
+
|
|
757
|
+
* Bump 0.0.4, run docs generation ([51a15fe](https://github.com/vkarpov15/kareem/commit/51a15fe))
|
|
758
|
+
* Use correct post parameters in wrap() ([9bb5da3](https://github.com/vkarpov15/kareem/commit/9bb5da3))
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
<a name="0.0.3"></a>
|
|
763
|
+
## <small>0.0.3 (2014-12-12)</small>
|
|
764
|
+
|
|
765
|
+
* Add npm test script, fix small bug with args not getting passed through post ([49e3e68](https://github.com/vkarpov15/kareem/commit/49e3e68))
|
|
766
|
+
* Bump 0.0.3 ([65621d8](https://github.com/vkarpov15/kareem/commit/65621d8))
|
|
767
|
+
* Update readme ([901388b](https://github.com/vkarpov15/kareem/commit/901388b))
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
<a name="0.0.2"></a>
|
|
772
|
+
## <small>0.0.2 (2014-12-12)</small>
|
|
773
|
+
|
|
774
|
+
* Add github repo and bump 0.0.2 ([59db8be](https://github.com/vkarpov15/kareem/commit/59db8be))
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
<a name="0.0.1"></a>
|
|
779
|
+
## <small>0.0.1 (2014-12-12)</small>
|
|
780
|
+
|
|
781
|
+
* Add basic docs ([ad29ea4](https://github.com/vkarpov15/kareem/commit/ad29ea4))
|
|
782
|
+
* Add pre hooks ([2ffc356](https://github.com/vkarpov15/kareem/commit/2ffc356))
|
|
783
|
+
* Add wrap function ([68c540c](https://github.com/vkarpov15/kareem/commit/68c540c))
|
|
784
|
+
* Bump to version 0.0.1 ([a4bfd68](https://github.com/vkarpov15/kareem/commit/a4bfd68))
|
|
785
|
+
* Initial commit ([4002458](https://github.com/vkarpov15/kareem/commit/4002458))
|
|
786
|
+
* Initial deposit ([98fc489](https://github.com/vkarpov15/kareem/commit/98fc489))
|
|
787
|
+
* Post hooks ([395b67c](https://github.com/vkarpov15/kareem/commit/395b67c))
|
|
788
|
+
* Some basic setup work ([82df75e](https://github.com/vkarpov15/kareem/commit/82df75e))
|
|
789
|
+
* Support sync pre hooks ([1cc1b9f](https://github.com/vkarpov15/kareem/commit/1cc1b9f))
|
|
790
|
+
* Update package.json description ([978da18](https://github.com/vkarpov15/kareem/commit/978da18))
|
package/index.js
CHANGED
|
@@ -137,7 +137,7 @@ Kareem.prototype.execPost = function(name, context, args, options, callback) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
var next = function() {
|
|
140
|
-
var post = posts[currentPost];
|
|
140
|
+
var post = posts[currentPost].fn;
|
|
141
141
|
var numArgs = 0;
|
|
142
142
|
var argLength = args.length;
|
|
143
143
|
var newArgs = [];
|
|
@@ -222,7 +222,7 @@ Kareem.prototype.execPostSync = function(name, context, args) {
|
|
|
222
222
|
const numPosts = posts.length;
|
|
223
223
|
|
|
224
224
|
for (let i = 0; i < numPosts; ++i) {
|
|
225
|
-
posts[i].apply(context, args || []);
|
|
225
|
+
posts[i].fn.apply(context, args || []);
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
|
|
@@ -320,6 +320,42 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
|
|
|
320
320
|
});
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
+
Kareem.prototype.filter = function(fn) {
|
|
324
|
+
const clone = this.clone();
|
|
325
|
+
|
|
326
|
+
const pres = Array.from(clone._pres.keys());
|
|
327
|
+
for (const name of pres) {
|
|
328
|
+
const hooks = this._pres.get(name).
|
|
329
|
+
map(h => Object.assign({}, h, { name: name })).
|
|
330
|
+
filter(fn);
|
|
331
|
+
|
|
332
|
+
if (hooks.length === 0) {
|
|
333
|
+
clone._pres.delete(name);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
hooks.numAsync = hooks.filter(h => h.isAsync).length;
|
|
338
|
+
|
|
339
|
+
clone._pres.set(name, hooks);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const posts = Array.from(clone._posts.keys());
|
|
343
|
+
for (const name of posts) {
|
|
344
|
+
const hooks = this._posts.get(name).
|
|
345
|
+
map(h => Object.assign({}, h, { name: name })).
|
|
346
|
+
filter(fn);
|
|
347
|
+
|
|
348
|
+
if (hooks.length === 0) {
|
|
349
|
+
clone._posts.delete(name);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
clone._posts.set(name, hooks);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return clone;
|
|
357
|
+
};
|
|
358
|
+
|
|
323
359
|
Kareem.prototype.hasHooks = function(name) {
|
|
324
360
|
return this._pres.has(name) || this._posts.has(name);
|
|
325
361
|
};
|
|
@@ -341,7 +377,11 @@ Kareem.prototype.createWrapper = function(name, fn, context, options) {
|
|
|
341
377
|
};
|
|
342
378
|
|
|
343
379
|
Kareem.prototype.pre = function(name, isAsync, fn, error, unshift) {
|
|
344
|
-
|
|
380
|
+
let options = {};
|
|
381
|
+
if (typeof isAsync === 'object' && isAsync != null) {
|
|
382
|
+
options = isAsync;
|
|
383
|
+
isAsync = options.isAsync;
|
|
384
|
+
} else if (typeof arguments[1] !== 'boolean') {
|
|
345
385
|
error = fn;
|
|
346
386
|
fn = isAsync;
|
|
347
387
|
isAsync = false;
|
|
@@ -355,22 +395,36 @@ Kareem.prototype.pre = function(name, isAsync, fn, error, unshift) {
|
|
|
355
395
|
++pres.numAsync;
|
|
356
396
|
}
|
|
357
397
|
|
|
398
|
+
if (typeof fn !== 'function') {
|
|
399
|
+
throw new Error('pre() requires a function, got "' + typeof fn + '"');
|
|
400
|
+
}
|
|
401
|
+
|
|
358
402
|
if (unshift) {
|
|
359
|
-
pres.unshift({ fn: fn, isAsync: isAsync });
|
|
403
|
+
pres.unshift(Object.assign({}, options, { fn: fn, isAsync: isAsync }));
|
|
360
404
|
} else {
|
|
361
|
-
pres.push({ fn: fn, isAsync: isAsync });
|
|
405
|
+
pres.push(Object.assign({}, options, { fn: fn, isAsync: isAsync }));
|
|
362
406
|
}
|
|
363
407
|
|
|
364
408
|
return this;
|
|
365
409
|
};
|
|
366
410
|
|
|
367
|
-
Kareem.prototype.post = function(name, fn, unshift) {
|
|
411
|
+
Kareem.prototype.post = function(name, options, fn, unshift) {
|
|
368
412
|
const hooks = get(this._posts, name, []);
|
|
369
413
|
|
|
414
|
+
if (typeof options === 'function') {
|
|
415
|
+
unshift = !!fn;
|
|
416
|
+
fn = options;
|
|
417
|
+
options = {};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (typeof fn !== 'function') {
|
|
421
|
+
throw new Error('post() requires a function, got "' + typeof fn + '"');
|
|
422
|
+
}
|
|
423
|
+
|
|
370
424
|
if (unshift) {
|
|
371
|
-
hooks.unshift(fn);
|
|
425
|
+
hooks.unshift(Object.assign({}, options, { fn: fn }));
|
|
372
426
|
} else {
|
|
373
|
-
hooks.push(fn);
|
|
427
|
+
hooks.push(Object.assign({}, options, { fn: fn }));
|
|
374
428
|
}
|
|
375
429
|
this._posts.set(name, hooks);
|
|
376
430
|
return this;
|
|
@@ -391,8 +445,9 @@ Kareem.prototype.clone = function() {
|
|
|
391
445
|
return n;
|
|
392
446
|
};
|
|
393
447
|
|
|
394
|
-
Kareem.prototype.merge = function(other) {
|
|
395
|
-
|
|
448
|
+
Kareem.prototype.merge = function(other, clone) {
|
|
449
|
+
clone = arguments.length === 1 ? true : clone;
|
|
450
|
+
var ret = clone ? this.clone() : this;
|
|
396
451
|
|
|
397
452
|
for (let key of other._pres.keys()) {
|
|
398
453
|
const sourcePres = get(ret._pres, key, []);
|
package/package.json
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kareem",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Next-generation take on pre/post function hooks",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "
|
|
8
|
-
"test-travis": "
|
|
7
|
+
"test": "mocha ./test/*",
|
|
8
|
+
"test-travis": "nyc mocha ./test/*"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git://github.com/vkarpov15/kareem.git"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"gulp-jscs": "1.4.0",
|
|
19
|
-
"istanbul": "0.4.5",
|
|
20
|
-
"jscs": "1.9.0",
|
|
21
|
-
"mocha": "3.2.0"
|
|
22
|
-
},
|
|
23
|
-
"jscsConfig": {
|
|
24
|
-
"preset": "airbnb",
|
|
25
|
-
"requireMultipleVarDecl": null,
|
|
26
|
-
"disallowMultipleVarDecl": true
|
|
15
|
+
"nyc": "11.x",
|
|
16
|
+
"mocha": "5.x",
|
|
17
|
+
"standard-version": "4.4.0"
|
|
27
18
|
},
|
|
28
19
|
"author": "Valeri Karpov <val@karpov.io>",
|
|
29
20
|
"license": "Apache-2.0"
|
package/test/misc.test.js
CHANGED
|
@@ -31,3 +31,41 @@ describe('merge', function() {
|
|
|
31
31
|
assert.equal(k3._pres.get('cook').numAsync, 1);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
describe('filter', function() {
|
|
36
|
+
it('returns clone with only hooks that match `fn()`', function() {
|
|
37
|
+
const k1 = new Kareem();
|
|
38
|
+
|
|
39
|
+
k1.pre('update', { document: true }, f1);
|
|
40
|
+
k1.pre('update', { query: true }, f2);
|
|
41
|
+
k1.pre('remove', { document: true }, f3);
|
|
42
|
+
|
|
43
|
+
k1.post('update', { document: true }, f1);
|
|
44
|
+
k1.post('update', { query: true }, f2);
|
|
45
|
+
k1.post('remove', { document: true }, f3);
|
|
46
|
+
|
|
47
|
+
const k2 = k1.filter(hook => hook.document);
|
|
48
|
+
assert.equal(k2._pres.get('update').length, 1);
|
|
49
|
+
assert.equal(k2._pres.get('update')[0].fn, f1);
|
|
50
|
+
assert.equal(k2._pres.get('remove').length, 1);
|
|
51
|
+
assert.equal(k2._pres.get('remove')[0].fn, f3);
|
|
52
|
+
|
|
53
|
+
assert.equal(k2._posts.get('update').length, 1);
|
|
54
|
+
assert.equal(k2._posts.get('update')[0].fn, f1);
|
|
55
|
+
assert.equal(k2._posts.get('remove').length, 1);
|
|
56
|
+
assert.equal(k2._posts.get('remove')[0].fn, f3);
|
|
57
|
+
|
|
58
|
+
const k3 = k1.filter(hook => hook.query);
|
|
59
|
+
assert.equal(k3._pres.get('update').length, 1);
|
|
60
|
+
assert.equal(k3._pres.get('update')[0].fn, f2);
|
|
61
|
+
assert.ok(!k3._pres.has('remove'));
|
|
62
|
+
|
|
63
|
+
assert.equal(k3._posts.get('update').length, 1);
|
|
64
|
+
assert.equal(k3._posts.get('update')[0].fn, f2);
|
|
65
|
+
assert.ok(!k3._posts.has('remove'));
|
|
66
|
+
|
|
67
|
+
function f1() {}
|
|
68
|
+
function f2() {}
|
|
69
|
+
function f3() {}
|
|
70
|
+
});
|
|
71
|
+
});
|
package/test/post.test.js
CHANGED
|
@@ -27,10 +27,23 @@ describe('execPost', function() {
|
|
|
27
27
|
var f2 = function() {};
|
|
28
28
|
hooks.post('cook', f1);
|
|
29
29
|
hooks.post('cook', f2, true);
|
|
30
|
-
assert.strictEqual(hooks._posts.get('cook')[0], f2);
|
|
31
|
-
assert.strictEqual(hooks._posts.get('cook')[1], f1);
|
|
30
|
+
assert.strictEqual(hooks._posts.get('cook')[0].fn, f2);
|
|
31
|
+
assert.strictEqual(hooks._posts.get('cook')[1].fn, f1);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
it('arbitrary options', function() {
|
|
35
|
+
const f1 = function() {};
|
|
36
|
+
const f2 = function() {};
|
|
37
|
+
hooks.post('cook', { foo: 'bar' }, f1);
|
|
38
|
+
hooks.post('cook', { bar: 'baz' }, f2, true);
|
|
39
|
+
assert.equal(hooks._posts.get('cook')[1].foo, 'bar');
|
|
40
|
+
assert.equal(hooks._posts.get('cook')[0].bar, 'baz');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('throws error if no function', function() {
|
|
44
|
+
assert.throws(() => hooks.post('test'), /got "undefined"/);
|
|
45
|
+
});
|
|
46
|
+
|
|
34
47
|
it('multiple posts', function(done) {
|
|
35
48
|
hooks.post('cook', function(eggs, callback) {
|
|
36
49
|
setTimeout(
|
package/test/pre.test.js
CHANGED
|
@@ -65,6 +65,19 @@ describe('execPre', function() {
|
|
|
65
65
|
assert.strictEqual(hooks._pres.get('cook')[1].fn, f1);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
it('throws error if no function', function() {
|
|
69
|
+
assert.throws(() => hooks.pre('test'), /got "undefined"/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('arbitrary options', function() {
|
|
73
|
+
const f1 = function() {};
|
|
74
|
+
const f2 = function() {};
|
|
75
|
+
hooks.pre('cook', { foo: 'bar' }, f1);
|
|
76
|
+
hooks.pre('cook', { bar: 'baz' }, f2, null, true);
|
|
77
|
+
assert.equal(hooks._pres.get('cook')[1].foo, 'bar');
|
|
78
|
+
assert.equal(hooks._pres.get('cook')[0].bar, 'baz');
|
|
79
|
+
});
|
|
80
|
+
|
|
68
81
|
it('handles async errors', function(done) {
|
|
69
82
|
var execed = {};
|
|
70
83
|
|