npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xaop

v2.1.0

Published

Typescript 的Aop实现. 有关AOP编程,其实就是在函数的运行时注入相应的代码,以达到分离实现的目的.(简单的说就是这样...)

Downloads

31

Readme

xaop

Typescript 的Aop实现. 有关AOP编程,其实就是在函数的运行时注入相应的代码,以达到分离实现的目的.(简单的说就是这样...)

所以现在这个库用装饰器实现了一个注入工具.可以直接通过 obj.func 直接输入起始和结束,并且可以得到参数和返回结果. 下面这个例子简单的描述了这个库的使用

##安装

npm i xaop

##升级

npm publish

##注意: 默认构造参数无法捕获初始化参数.

function add(a,b=1) //这里的b是无法捕获到的
{

}

##全局注入

class E
{
    @iaop
    exec()
    {
        console.log("hello e");
    }
}

let e = new E();
let remove1 = xaop.begin(e.exec, () =>
{
    console.log("begin");
})

let remove2 = xaop.end(e.exec, function()
{
    //如果你不使用箭头函数 你可以捕获到this.
    console.log("end");
})

e.exec();
//begin
//hello e
//end
remove1();//清除注入
remove2();//清除注入
e.exec();
//hello e

##对象注入

class E
{
    exec()
    {
        console.log("hello e");
    }
}

let e=new E()
let e2=new E();
xaop.begin(e,e.exec,()=>{
    console.log("hello begin");
})

e.exec();
/*
hello begin
hello e
*/

//不影响e2的响应
e2.exec()
/*
hello e
*/