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

data-interact

v1.1.7

Published

Listen to reference data and intercept it asynchronously when modifying data

Readme

data-interact

深度监听数据,并且可以拦截对数据的修改,以事件监听,代理为核心驱动

安装

npm install data-interact

使用

import responsive from 'data-interact'

const line1 = responsive({
  line: {
    points: [
      {x: 0, y: 0},
      {x: 1, y: 1}
    ]
  }
})

const point1 = responsive({x: 0, y: 0})
const point2 = responsive({x: 1, y: 1})
const line2 = responsive({
  line: {
    points: [point1.api.origin. point2.api.origin] 
  }
})

// 直接拦截宿主修改,参数为修改的路径,返回false 则不修改
line1.api.stop(({ points }) => {
  if (points.length !== 2) 
    return false;
})

// 拦截宿主下的某个属性
line1.api.stop('points.0', (point) => {
  if (point.x > 10) 
    return false;
})

//修改无效
line1.points = 2
line1.points[0].x = 18

//修改有效
line1.points = [
  {x: 1, y: 1},
  {x: 2, y: 2}
]
line1.points[0].x = 9

API

| 方法 | 说明 | 回调参数 | 回调应返回 | | ---- | ---- | ---- | ---- | | stop([local], calaabck) | 拦截指定参数修改 local: string 拦截路径, 可选 callback: function 回调函数,可在回调函数中返回对象,该对象key对应修改key时将覆盖上一次的修改,如返回{x: -1} 那么x将永远是-1 | 被修改的对象 | false | {(key: string): any} | | removeStop([local], calaabck) | 移除拦截函数 local: string 拦截路径, 可选 callback: function 回调函数 | | onceStop([local], calaabck) | 拦截一次指定参数修改 local: string 拦截路径, 可选 callback: function 回调函数,可在回调函数中返回对象,该对象key对应修改key时将覆盖上一次的修改,如返回{x: -1} 那么x将永远是-1 | 被修改的对象 | false | {(key: string): any} | | update([local], calaabck) | 监听对象发生改变时 local: string 拦截路径, 可选 callback: function 回调函数 | 被修改的对象 | | removeUpdate([local], calaabck) | 移除监听对象发生改变时 local: string 拦截路径, 可选 callback: function 回调函数 |
| onceUpdate([local], calaabck) | 监听一次对象发生改变时 local: string 拦截路径, 可选 callback: function 回调函数 | 被修改的对象 | | nextTick([local], calaabck) | 当数据下次变化时,注意只有当属性不再修改队列中或没有修改才会触发回调 local: string 拦截路径, 可选 callback: function 回调函数 | void | | setPattern(isAsync) | 设置当前模式, isAsync: boolean 同步还是异步 同步模式下不会发送 stop事件提供检查,会直接修改成功,并发送update事件 | void |

Attr

| 属性 | 说明 | | ---- | ---- | | origin | 没有被代理前的对象 | | old | 被修改前的值,再拦截期间直接用对象获取值将拿到拦截期间的值,再拦截后才会变成真值,用此属性可以获取到真正的值|