Introspected
Introspection for serializable arrays and JSON friendly objects.
[Medium presentation post](https://medium.com/@WebReflection/introspected-js-objects-without-secrets-55cf0bd3dccc) - - - The project is written primarily in HTML, distributed under the ISC License license, first published in 2017. Key topics include: deep, introspection, json, notifications, proxy.
Introspected
If you'd like to be notified about any possible change that could happen to a JSON compatible model / data / object / array / structure,
including the possibility to retrieve the exact full path of the object that changed and eventually walk through it,
you've reached your destination.
jsconst data = Introspected( // any object or JSON compatible structure // even with nested properties, objects, arrays JSON.parse('{}'), (root, path) => { // the root object that changed console.log(root); // the path that just changed console.log(path); } ); // now try the following in console data.a.b.c.d.e.f.g = 'whatever'; data.array.value = [1, 2, 3]; data.array.value.push(4); // see all notifications about all changes 🎉 JSON.stringify(data); // {"a":{"b":{"c":{"d":{"e":{"f":{"g":"whatever"}}}}}},"array":{"value":[1,2,3,4]}}
API
Introspected(objectOrArray[, callback])create a newIntrospectedobject capable of having infinite depth without ever throwing errorsIntrospected.observe(objectOrArray, callback)crate aIntrospectedwith a notifier per each change, or set a notifier per each change to an existentIntrospectedobjectIntrospected.pathValue(objectOrArray, path)walk through an object via a provided path. Apathis anArrayof properties, it is usually the one received through the notifier whenever aIntrospectedobject is observed.
Compatibility
Any spec compliant ES2015 JavaScript engine.
<sup>(that means native WeakMap, Proxy and Symbol.toPrimitive too)</sup>
Working: NodeJS 6+, Chrome, Safari, GNOME Web, Edge, Firefox, Samsung Internet (Chrome 51)
Not there yet: UC Browser (WebKit 534)
ISC License
Contributors
Showing top 1 contributor by commit count.
