custom-decorators
Advanced tools
Comparing version
{ | ||
"name": "custom-decorators", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "type": "module", | ||
"author": "", | ||
"license": "ISC" | ||
"license": "MIT" | ||
} |
@@ -11,3 +11,3 @@ | ||
```js | ||
import custom from '@ali/custom'; | ||
import custom from 'custom-decorators'; | ||
@@ -42,1 +42,28 @@ class ClassA { | ||
# Features | ||
* 支持同步 | ||
```js | ||
class ClassA { | ||
@custom('ClassA.method', { sync: true }) | ||
method(name) { | ||
console.log(`hello ${name}`); | ||
} | ||
} | ||
// 注意插件函数也需要是同步,不要添加 async 关键字 | ||
custom('ClassA.method', function(context, next) { | ||
const { args } = context; | ||
console.log(this, 'before', args[0]); | ||
next(); | ||
console.log(this, 'after', args[0]); | ||
}) | ||
``` | ||
# Limit | ||
* 仅支持标准 JS 写法, 不支持 TS 写法 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15058
0.63%68
65.85%419
-3.01%