UNPKG

@stimulus-library/utilities

Version:

A library of useful controllers for Stimulus

21 lines (20 loc) 573 B
export function reactive(object) { if (object === null || typeof object !== "object") { return object; } for (const property in object) { if (Object.getOwnPropertyDescriptor(object, property) == undefined) { continue; } object[property] = reactive(object[property]); } return new Proxy(object, { get(target, property) { return target[property]; }, set(target, property, value) { target[property] = reactive(value); return true; }, }); }