{"repo":"sindresorhus/on-change","free":true,"listed":false,"github":"https://github.com/sindresorhus/on-change","clone":"git clone https://github.com/sindresorhus/on-change.git","description":"Watch an object or array for changes","language":"JavaScript","stars":2029,"topics":["watch","object","change-detection","es2015-proxy","nodejs","npm-package"],"license":"MIT","category":"dev-tools","readme_excerpt":"on-change Watch an object or array for changes It works recursively, so it will even detect if you modify a deep property like obj.a.b[0].c = true . Uses the Proxy API. Install Usage API onChange(object, onChange, options?) Returns a version of object that is watched. It's the exact same object, just with some Proxy traps. object Type: object Object to watch for changes. onChange Type: Function Function that gets called anytime the object changes. The function receives four arguments: 1. A path to the value that was changed. A change to c in the above example would return a.b.0.c . 2. The new value at the path. 3. The previous value at the path. Changes in WeakSets and WeakMaps will return undefined . 4. An object with the name of the method that produced the change, the args passed to the method, and the result of the method. The context (this) is set to the original object passed to onChange (with Proxy). options Type: object Options for altering the behavior of onChange. isShallow Type: boolean \\ Default: false Deep changes will not trigger the callback. Only changes to the immediate properties of the original object. equals Type: Function \\ Default: Object.is The function receives two arguments to be compared for equality. Should return true if the two values are determined to be equal. Useful if you only need a more loose form of equality. ignoreSymbols Type: boolean \\ Default: false Setting properties as Symbol won't trigger the callback. ignoreKeys Type: Array \\ Defaul","default_branch":null,"files":null,"tree":[],"storefront":"/r/sindresorhus","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sindresorhus/on-change/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}