Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

on-change

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

on-change - npm Package Compare versions

Comparing version 1.6.1 to 1.6.2

27

index.d.ts

@@ -76,3 +76,2 @@ declare namespace onChange {

@param onChange - Function that gets called anytime the object changes.
@param [options]
@returns A version of `object` that is watched. It's the exact same object, just with some `Proxy` traps.

@@ -146,3 +145,3 @@

*/
<ObjectType extends {[key: string]: unknown}>(
<ObjectType extends {[key: string]: any}>(
object: ObjectType,

@@ -167,20 +166,16 @@ onChange: (

/**
* Returns the original unwatched object.
*
* @param object - Object that is already being watched for changes.
*
* @returns The original unwatched object.
*/
target(object: object): object;
@param object - Object that is already being watched for changes.
@returns The original unwatched object.
*/
target<ObjectType extends {[key: string]: any}>(object: ObjectType): ObjectType;
/**
* Cancels all future callbacks on a watched object and returns the original unwatched object.
*
* @param object - Object that is already being watched for changes.
*
* @returns The original unwatched object.
*/
unsubscribe(object: object): object;
Cancels all future callbacks on a watched object.
@param object - Object that is already being watched for changes.
@returns The original unwatched object.
*/
unsubscribe<ObjectType extends {[key: string]: any}>(object: ObjectType): ObjectType;
};
export = onChange;

@@ -142,2 +142,6 @@ 'use strict';

const ignoreChange = property => {
return isUnsubscribed || (options.ignoreSymbols === true && typeof property === 'symbol');
};
const handler = {

@@ -183,7 +187,7 @@ get(target, property, receiver) {

const ignore = options.ignoreSymbols === true && typeof property === 'symbol';
const ignore = ignoreChange(property);
const previous = ignore ? null : Reflect.get(target, property, receiver);
const result = Reflect.set(target[proxyTarget] || target, property, value);
if (!isUnsubscribed && !ignore && !equals(previous, value)) {
if (!ignore && !equals(previous, value)) {
handleChange(pathCache.get(target), property, previous, value);

@@ -197,6 +201,9 @@ }

const result = Reflect.defineProperty(target, property, descriptor);
invalidateCachedDescriptor(target, property);
handleChange(pathCache.get(target), property, undefined, descriptor.value);
if (!ignoreChange(property)) {
invalidateCachedDescriptor(target, property);
handleChange(pathCache.get(target), property, undefined, descriptor.value);
}
return result;

@@ -210,8 +217,12 @@ },

const previous = Reflect.get(target, property);
const ignore = ignoreChange(property);
const previous = ignore ? null : Reflect.get(target, property);
const result = Reflect.deleteProperty(target, property);
invalidateCachedDescriptor(target, property);
handleChange(pathCache.get(target), property, previous);
if (!ignore) {
invalidateCachedDescriptor(target, property);
handleChange(pathCache.get(target), property, previous);
}
return result;

@@ -218,0 +229,0 @@ },

{
"name": "on-change",
"version": "1.6.1",
"version": "1.6.2",
"description": "Watch an object or array for changes",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc