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

@cuberqaq/zeppos-reactive

v1.0.0

Published

轻量响应式系统,适用于 Zepp OS / 受限运行环境

Readme

@x1a0ma17x/zeppos-reactive

一个极轻量、零依赖、适用于 ZeppOS / 小程序 / 受限环境的响应式系统。

  • ✅ reactive() —— 深度响应式对象

  • ✅ effect() —— 自动依赖收集 & 响应式副作用

  • ✅ computed() —— 具备缓存的计算属性(推 + 拉混合模型)

  • ✅ 无 Proxy polyfill 依赖

  • ✅ 无 effect 栈、无 scheduler 的极简实现

  • ✅ 适合 ZeppOS、IoT、小程序等受限运行环境

📦 安装

npm install @x1a0ma17x/zeppos-reactive

或使用 pnpm:

pnpm add @x1a0ma17x/zeppos-reactive

🚀 快速开始

import { reactive, effect, computed } from "@x1a0ma17x/zeppos-reactive";

const state = reactive({
  count: 1,
  nested: { value: 10 }
});

effect(() => {
  console.log("count changed:", state.count);
});

state.count++; // 自动触发 effect

📘 API 文档

1. reactive()

创建一个深度响应式对象。

const obj = reactive({ a: 1, b: { c: 2 } });
特点:
  • ✅ 深度代理(嵌套对象自动 reactive)

  • ✅ 访问属性时自动 track

  • ✅ 修改属性时自动 trigger

  • ✅ 不会重复代理同一个对象

示例:
const state = reactive({
  count: 0,
  nested: { value: 100 }
});

effect(() => {
  console.log("nested.value =", state.nested.value);
});

state.nested.value = 200; // 自动触发 effect

2. effect()

注册一个副作用函数,当其依赖的响应式数据变化时自动重新执行。

effect(() => {
  console.log("count is", state.count);
});
特点:
  • ✅ 自动依赖收集

  • ✅ 支持嵌套 effect

  • ✅ 支持动态依赖切换

  • ✅ 调用栈即 effect 栈,无需额外维护

示例:动态依赖切换
const state = reactive({ flag: true, a: 1, b: 2 });

effect(() => {
  console.log(state.flag ? state.a : state.b);
});

state.flag = false; // effect 自动切换依赖到 state.b
state.b = 100;      // 触发 effect

3. computed()

创建一个具备缓存的计算属性。

const double = computed(() => state.count * 2);

console.log(double.value); // 2
state.count++;
console.log(double.value); // 4
特点:
  • ✅ 首次访问时计算

  • ✅ 缓存结果

  • ✅ 依赖变化时自动更新

  • ✅ 只有在被 effect 依赖时才会主动触发更新(推式)

  • ✅ 在非 effect 中访问时按需重新计算(拉式)

示例:computed 依赖 effect
const sum = computed(() => state.a + state.b);

effect(() => {
  console.log("sum =", sum.value);
});

state.a = 10; // 自动触发 effect