
Research
/Security News
OpenAPI React Query Codegen Compromised in Mini Shai-Hulud npm Supply Chain Attack
Ten malicious OpenAPI React Query Codegen versions were published to npm in the Mini Shai-Hulud attack, all with valid provenance.
@ismartify/reactive
Advanced tools
[](https://badge.fury.io/js/%40ismartify%2Freactive) [](https://opensource.org/licenses/ISC)
一个基于 Vue 3 Reactivity 和 Lodash 的响应式对象操作工具库,为响应式数据提供简洁易用的链式操作接口。
# 使用 npm
npm install @ismartify/reactive
# 使用 pnpm
pnpm add @ismartify/reactive
# 使用 yarn
yarn add @ismartify/reactive
import { reactive } from '@vue/reactivity';
import { ISmartifyReactive } from '@ismartify/reactive';
// 创建响应式对象
const reactiveObj = reactive({
user: {
name: 'John Doe',
age: 30,
settings: {
theme: 'dark',
notifications: true
}
},
posts: []
});
// 创建 ISmartifyReactive 实例
const store = new ISmartifyReactive(reactiveObj);
// 链式操作
store
.set('user.age', 31)
.set('posts', [{ id: 1, title: 'Hello World' }])
.tap(); // 输出当前状态
// 获取嵌套属性
const userName = store.get('user.name'); // 'John Doe'
const theme = store.get('user.settings.theme'); // 'dark'
// 挑选属性
const userInfo = store.pick(['user.name', 'user.age']);
// { 'user.name': 'John Doe', 'user.age': 31 }
// 获取原始响应式对象
const raw = store.raw();
new ISmartifyReactive(reactiveObject?: Record<string, any>)
reactiveObject: 可选的 Vue 响应式对象。如果不传入,将创建一个空的响应式对象。注意:传入的对象必须是使用 reactive() 创建的响应式对象,否则会抛出错误。
get<T>(key: string, defaultValue?: T): T | undefined获取指定路径的值,支持嵌套路径。
const value = store.get('user.settings.theme');
const valueWithDefault = store.get('user.email', 'default@email.com');
set<T>(key: string, value: T): this设置指定路径的值,返回实例本身支持链式调用。
store.set('user.name', 'Jane Doe').set('user.age', 25);
pick(pattern: string | string[]): Record<string, any>从对象中挑选指定的属性。
// 单个属性
const name = store.pick('user.name'); // { 'user.name': 'Jane Doe' }
// 多个属性
const userInfo = store.pick(['user.name', 'user.age']);
tap(fn?: (store: Record<string, any>) => void): this调试方法,用于查看当前存储状态,默认输出到控制台。
// 默认输出
store.tap();
// 自定义处理
store.tap((data) => {
console.log('Current state:', data);
// 进行其他操作...
});
mixin<T>(name: string, fn: (self: this, ...args: any[]) => T): this添加自定义方法到存储实例,返回实例本身支持链式调用。
// 添加自定义方法
store.mixin('double', function(self, multiplier = 2) {
const current = self.get('value');
return current * multiplier;
});
// 链式调用
store.mixin('reset', function(self) {
self.set('value', 0);
return '已重置';
});
call<T>(name: string, ...args: any[]): T调用通过 mixin 方法添加的自定义函数。
// 调用混入的方法
const result = store.call('double', 3); // 返回 30
const resetMsg = store.call('reset'); // 返回 '已重置'
exec<T>(fn: (self: this) => T): T执行回调函数,可以在回调中操作存储并返回结果。
// 执行复杂逻辑
const result = store.exec((self) => {
const current = self.get('counter');
self.set('counter', current + 10);
self.set('history', [...self.get('history'), current + 10]);
return `计数器更新为: ${current + 10}`;
});
raw(): Record<string, any>返回原始的响应式对象。
const original = store.raw();
// 直接操作原始对象,但会失去响应式特性
get(object: any, path: string, defaultValue?: any): anyLodash 的 get 函数,用于安全地获取嵌套对象属性。
set(object: any, path: string, value: any): anyLodash 的 set 函数,用于设置嵌套对象属性。
pick(object: any, paths: string | string[]): Record<string, any>Lodash 的 pick 函数,用于从对象中挑选指定的属性。
isReactive(value: unknown): boolean检查一个值是否为 Vue 响应式对象。
import { reactive } from '@vue/reactivity';
import { isReactive } from '@ismartify/reactive';
const obj = { name: 'test' };
const reactiveObj = reactive(obj);
console.log(isReactive(obj)); // false
console.log(isReactive(reactiveObj)); // true
# 安装依赖
pnpm install
# 运行测试
pnpm test
# 构建项目
pnpm build
# 发布到 npm
pnpm run npm:publish
ISC License
欢迎提交 Issue 和 Pull Request!
FAQs
[](https://badge.fury.io/js/%40ismartify%2Freactive) [](https://opensource.org/licenses/ISC)
We found that @ismartify/reactive demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.

Research
/Security News
Ten malicious OpenAPI React Query Codegen versions were published to npm in the Mini Shai-Hulud attack, all with valid provenance.

Security News
Socket joins more than 100 technology, cybersecurity, and financial organizations calling for a global surge in cyber defense.

Product
Enterprise security teams can now detect malware, credential theft, suspicious network activity, and risky updates across Microsoft Edge extensions.