Skip to content

Commit 08f163e

Browse files
committed
0.3.0
1 parent e9b7661 commit 08f163e

File tree

9 files changed

+50
-19
lines changed

9 files changed

+50
-19
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,22 @@ const PersonMiddleware = {
105105
```
106106

107107
## middlewareMethods
108-
Or we can use `middlewareMethods` to define function names for middleweare target within a class.
108+
In a class, function's name start or end with "_" will not be able to apply as middleware.
109+
Or we can use `middlewareMethods` to define function names for middleware target within a class.
109110

110111
```
111112
class PersonMiddleware {
112113
constructor() {
113114
/**
114-
* Define function names for middleweare target.
115+
* Or Define function names for middleweare target.
115116
* @type {Array}
116117
*/
117118
this.middlewareMethods = ['walk', 'speak'];
118119
}
120+
// Function's name start or end with "_" will not be able to apply as middleware.
121+
_getPrefix() {
122+
return 'Middleware log: ';
123+
}
119124
log(text) {
120125
console.log('Middleware log: ' + text);
121126
}

dist/middleware.js

Lines changed: 22 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/middleware.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/html/MiddlewareManager.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,20 @@ <h5>Example</h5>
252252
p.speak(&#x27;hi&#x27;);
253253

254254
## middlewareMethods
255+
In a class, function&#x27;s name start or end with &quot;_&quot; will not be able to apply as middleware.
255256
Or we can use &#x60;middlewareMethods&#x60; to define function names for middleware target within a class.
256257

257258
class PersonMiddleware {
258259
constructor() {
259-
//Define function names for middleware target.
260+
// Or Define function names for middleware target.
260261
this.middlewareMethods = [&#x27;walk&#x27;, &#x27;speak&#x27;];
261262
}
263+
// Function&#x27;s name start or end with &quot;_&quot; will not be able to apply as middleware.
264+
_getPrefix() {
265+
return &#x27;Middleware log: &#x27;;
266+
}
262267
log(text) {
263-
console.log(&#x27;Middleware log: &#x27; + text);
268+
console.log(this._getPrefix() + text);
264269
}
265270
walk(target) {
266271
return next =&gt; step =&gt; {
@@ -1001,7 +1006,7 @@ <h4 class="modal-title">Search results</h4>
10011006
<span class="jsdoc-message">
10021007
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
10031008

1004-
on 2017-04-26
1009+
on 2017-05-27
10051010

10061011
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
10071012
</span>

docs/html/classes.list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ <h4 class="modal-title">Search results</h4>
205205
<span class="jsdoc-message">
206206
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
207207

208-
on 2017-04-26
208+
on 2017-05-27
209209

210210
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
211211
</span>

docs/html/global.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h4 class="modal-title">Search results</h4>
367367
<span class="jsdoc-message">
368368
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
369369

370-
on 2017-04-26
370+
on 2017-05-27
371371

372372
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
373373
</span>

docs/html/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,20 @@ <h2>Middleware object</h2><p>We can also apply a middleware object to a target o
163163
const middlewareManager = new MiddlewareManager(p);
164164
middlewareManager.use(PersonMiddleware);
165165
p.walk(3);
166-
p.speak('hi');</code></pre><h2>middlewareMethods</h2><p>Or we can use <code>middlewareMethods</code> to define function names for middleweare target within a class.</p>
166+
p.speak('hi');</code></pre><h2>middlewareMethods</h2><p>In a class, function's name start or end with &quot;_&quot; will not be able to apply as middleware.
167+
Or we can use <code>middlewareMethods</code> to define function names for middleware target within a class.</p>
167168
<pre class="prettyprint source"><code>class PersonMiddleware {
168169
constructor() {
169170
/**
170-
* Define function names for middleweare target.
171+
* Or Define function names for middleweare target.
171172
* @type {Array}
172173
*/
173174
this.middlewareMethods = ['walk', 'speak'];
174175
}
176+
// Function's name start or end with &quot;_&quot; will not be able to apply as middleware.
177+
_getPrefix() {
178+
return 'Middleware log: ';
179+
}
175180
log(text) {
176181
console.log('Middleware log: ' + text);
177182
}
@@ -279,7 +284,7 @@ <h4 class="modal-title">Search results</h4>
279284
<span class="jsdoc-message">
280285
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
281286

282-
on 2017-04-26
287+
on 2017-05-27
283288

284289
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
285290
</span>

0 commit comments

Comments
 (0)