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 🙏

© 2026 – Pkg Stats / Ryan Hefner

event-propagation

v1.3.1

Published

This is an event-like event capture and bubbling event triggering mechanism based on eventMitter3 using typescript implemented in HtmlElement

Readme

这基于eventmitter3,它实现了类似于DOM事件的事件消息订阅,可以冒泡和捕获传播

This is based on eventmitter3, which implements event message subscriptions similar to DOM events that can bubble and capture propagation  

    import {EventTarget,Event,EventPhase} from 'event-propagation'

    // bubbles:Whether to support bubbles, default to true
    // cancelable: Whether to support cancel the default behavior, the default is true
    const e=new Event(type:string, bubbles?:boolean, cancelable?:boolean)
    
    e.preventDefault() //Block the default behavior of events, you need to implement the default behavior logic of blocking yourself.
    e.stopPropagation() // Stop propagating events up or down
    e.stopImmediatePropagation() // As above, and stop triggering of subsequent events of the current object
    const target1=new EventTarget()
    const target2=new EventTarget()
    const target3=new EventTarget()


    target2.parentNode=target1
    target3.parentNode=target2

    //e.target==target1,e.currentTarget===target3
    // print 1,2,3
    target1.on('mousedown',e=>{
        console.log(e.eventPhase)
        consolog.og('1',e.target==target1,e.currentTarget===target3)
    },{capture:true})

    target2.on('mousedown',e=>{
        consolog.og('3')
    })

    target3.on('mousedown',e=>{
            consolog.og('2')
    })
    target3.emit(e.setData()) // Trigger event or target3.dispatchEvent(e) // Trigger event



  // print 1,2,3
    target1.on('mousedown',e=>{
        consolog.og('3')
    },{capture:false})

    target2.on('mousedown',e=>{
        consolog.og('2')
    })

    target3.on('mousedown',e=>{
            consolog.og('1')
    })
    target3.emit(e) // Trigger event or target3.dispatchEvent(e) // Trigger event
 

   // print 1,2
    target1.on('mousedown',e=>{
        consolog.og('3')
    },{capture:false})

    target2.on('mousedown',e=>{
        e.stopPropagation()
        consolog.og('2')
    })

    target3.on('mousedown',e=>{
            consolog.og('1')
    })
    target3.emit(e) // Trigger event or target3.dispatchEvent(e) // Trigger event
 

 
   // print 3
    target1.on('mousedown',e=>{
        consolog.og('3')
        e.stopPropagation()
    },{capture:true})

    target2.on('mousedown',e=>{
        consolog.og('2')
    })

    target3.on('mousedown',e=>{
            consolog.og('1')
    })
    target3.emit(e) // Trigger event or target3.dispatchEvent(e) // Trigger event
 

Examples of event bubbling and capture applied in graphics engines

    import {EventTarget,Event,EventPhase} from 'event-propagation'
    class DisplayObject extends EventTarget<{
        mousedown:{},

    }>{
        type='container'
        children=[]
        add(child: DisplayObject) {
            child.parentNode=this
            this.children.push(child)
        }   

    }
    let container=new DisplayObject()
    let child=new DisplayObject()
    container.add(child)

    canvas.addEventListener('mousedown',e=>{
        let hitObj=findHitObject(e.x,e.y)
        hitObj.emit(Event.create(e.type).setData({x:e.x,y:e.y}))
    })

    container.on('mousedown',e=>{
        console.log('container mouseDown',e.eventPhase)
    })
    // Higher priority, capture phase triggers
     container.on('mousedown',e=>{
       // e.stopPropagation()
        console.log('container mouseDown',e.eventPhase)
    },{
        capture:true, // Capture phase triggers
    })
    child.on('mousedown',e=>{
        console.log('type',e.currentTarget.type)
        e.stopImmediatePropagation() // Prevents triggering of peer and parent events
        e.stopPropagation() // Prevent the triggering of parent events
        console.log('child mouseDown',e.eventPhase)
    })
  
     child.on('mousedown',e=>{
        console.log('child mouseDown2',e.eventPhase)
    })
    // output log
    // capture-container mouseDown 3
    // child mouseDown 2
    // container mouseDown 1