Wraps the value into a proxy and returns a WatchResult to track the property (and sub-property) access of the object and compare objects.
value
WatchResult
WatchResult object that holds the proxy for the value and watcher object that tracks property access and does the comparison.
proxy
watcher
Here's an example with different objects, but unchanged accessed properties:
import { watch } from '@indutny/sneequals';const value = { a: { b: 1 } };const { proxy, watcher } = watch(value);const derived = watcher.unwrap({ b: proxy.a.b });// Further access to `proxy` (or its sub-proxies) would throw.watcher.stop();// Prints `{ b: 1 }`console.log(derived);const sameProperties = { a: { b: 1 } };// Prints `false` because these are different objects.console.log(sameProperties === value);// Prints `false` because the tracked `value.a.b` didn't change.console.log(watcher.isChanged(value, sameProperties));
input value which could be a plain object, array, function or a primitive.
Generated using TypeDoc
Wraps the
valueinto a proxy and returns aWatchResultto track the property (and sub-property) access of the object and compare objects.See
WatchResult
Returns
WatchResult object that holds the
proxyfor thevalueandwatcherobject that tracks property access and does the comparison.Example
Here's an example with different objects, but unchanged accessed properties: