mm_machine 1.6.7 → 1.6.9
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/demo/test1/index.js +11 -2
- package/demo/test2/index.js +1 -1
- package/demo2/test1/index.js +10 -1
- package/index.js +15 -2
- package/package.json +1 -1
package/demo/test1/index.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
var i = 0;
|
|
3
3
|
function test() {
|
|
4
|
-
console.log("你好
|
|
4
|
+
console.log("你好7654321", i++)
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function main() {
|
|
8
8
|
test();
|
|
9
|
+
return i;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
exports.main = main;
|
|
12
|
+
exports.main = main;
|
|
13
|
+
|
|
14
|
+
exports.main_before = function(){
|
|
15
|
+
console.log("请求前")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.main_after = function(ret){
|
|
19
|
+
console.log("请求后", ret)
|
|
20
|
+
}
|
package/demo/test2/index.js
CHANGED
package/demo2/test1/index.js
CHANGED
|
@@ -6,6 +6,15 @@ function test() {
|
|
|
6
6
|
|
|
7
7
|
function main() {
|
|
8
8
|
test();
|
|
9
|
+
return i;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
exports.main = main;
|
|
12
|
+
exports.main = main;
|
|
13
|
+
|
|
14
|
+
exports.main_before = function(){
|
|
15
|
+
console.log("请求前")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.main_after = function(ret){
|
|
19
|
+
console.log("请求后", ret)
|
|
20
|
+
}
|
package/index.js
CHANGED
|
@@ -324,9 +324,22 @@ Item.prototype.main = function(param1, param2) {
|
|
|
324
324
|
* @param {Object} params 参数集合
|
|
325
325
|
* @return {Object} 执行结果
|
|
326
326
|
*/
|
|
327
|
-
Item.prototype.run = function(method, ...params) {
|
|
327
|
+
Item.prototype.run = async function(method, ...params) {
|
|
328
328
|
if (this.config.state && this[method]) {
|
|
329
|
-
|
|
329
|
+
if (this[method + "_before"]) {
|
|
330
|
+
this[method + "_before"](...params);
|
|
331
|
+
}
|
|
332
|
+
var ret = this[method](...params);
|
|
333
|
+
if (util.types.isPromise(ret)) {
|
|
334
|
+
ret = await ret;
|
|
335
|
+
}
|
|
336
|
+
if (this[method + "_after"]) {
|
|
337
|
+
ret = this[method + "_after"](ret, ...params) || ret;
|
|
338
|
+
}
|
|
339
|
+
if (util.types.isPromise(ret)) {
|
|
340
|
+
ret = await ret;
|
|
341
|
+
}
|
|
342
|
+
return ret
|
|
330
343
|
}
|
|
331
344
|
};
|
|
332
345
|
|