目标
判断是否由 reactive 或 readonly 创建的响应性对象
即结合 isReactive 和 isReadonly 判断即可
it('reactive', () => {
const original = { foo: 1 };
const observed = reactive(original);
expect(isProxy(observed)).toBe(true);
});
it('happy path', () => {
const original = { foo: 1, bar: { baz: 2 } };
const wrapped = readonly(original);
expect(isProxy(wrapped)).toBe(true);
});
实现
export function isProxy(value) {
return isReactive(value) || isReadonly(value);
}