Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
custom-decorators
Advanced tools
使用标准的装饰器语法,轻松实现对原有代码的开放、扩展。
插件的写法,遵循 koa-compose 的中间件写法。
import custom from 'custom-decorators';
class ClassA {
@custom('ClassA.method')
method(name) {
console.log(`hello ${name}`);
}
}
custom('ClassA.method', async function(context, next) {
const { args } = context;
console.log(this, 'before', args[0]);
await next();
console.log(this, 'after', args[0]);
})
const instancea = new ClassA();
instancea.method('world');
/* output
ClassA {} before world
hello world
ClassA {} after world
*/
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]);
})
FAQs
[![npm](https://img.shields.io/npm/v/custom-decorators.svg)](https://www.npmjs.com/package/custom-decorators) [![npm](https://img.shields.io/npm/dy/custom-decorators.svg)](https://www.npmjs.com/package/custom-decorators)
The npm package custom-decorators receives a total of 0 weekly downloads. As such, custom-decorators popularity was classified as not popular.
We found that custom-decorators demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.