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

@daoxin/observer

v0.0.1

Published

监听者<Observer>

Downloads

2

Readme

@daoxin/observer

安装

npm install @daoxin/observer

对象模型

| 类型成员 | 描述 | | ------------ | -------------------------- | | - _eventPool | 监听处理函数存储池 | | + on () | 绑定监听函数 | | + off () | 移除监听函数 | | + fire () | 触发监听函数 | | + onve () | 绑定监听函数(仅监听一次) |

使用

import Observer from '@daoxin/observer'

class TestClass extends Observer<{
  'inc': { value: number },
  'dev': { val: number }
}> {
  private _value = 1
  constructor () {
    super()
  }
  inc () : void {
    this._value++
    this.fire('inc', {
      value: this._value
    })
  }
  dec () : void {
    this._value--
    this.fire('dev', {
      val: this._value
    })
  }
}
const testObj = new TestClass()
let count = 0
testObj.on('inc', () => {
  count++
})
testObj.on('dev', () => {
  count++
})
testObj.inc() // +1
testObj.inc() // +1
testObj.inc() // +1
testObj.dec() // +1
testObj.dec() // +1
// output: count = 5
const testObj = new TestClass()
let count = 0
const handler = testObj.on('inc', () => {
count++
})
testObj.on('dev', () => {
count++
})
testObj.inc() // +1
testObj.inc() // +1
handler.remove()
testObj.dec() // +1
testObj.inc()
testObj.dec() // +1
// output: count = 4
const testObj = new TestClass()
let count = 0
testObj.on('inc', () => {
  count++
})
testObj.on('inc', () => {
  count++
})
testObj.on('dev', () => {
  count++
})
testObj.inc() // +2
testObj.dec() // +1
testObj.off('inc')
testObj.inc()
testObj.inc()
testObj.dec() // +1
// output: count = 4
const testObj = new TestClass()
let count = 0
const handler = testObj.on('inc', () => {
  count++
})
testObj.off('inc')
handler.remove()
testObj.inc()
// output: count = 0
const testObj = new TestClass()
let count = 0
const handler = testObj.on('inc', () => {
  count++
  handler.remove()
})
testObj.inc()
testObj.inc()
// output: count = 1
echo "# observer" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/dao-projects/observer.git
git push -u origin main


git remote add origin https://github.com/dao-projects/observer.git
git branch -M main
git push -u origin main