Socket
Socket
Sign inDemoInstall

proxy-compare

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-compare

Compare two objects using accessed properties with Proxy


Version published
Weekly downloads
528K
decreased by-12.73%
Maintainers
1
Weekly downloads
 
Created

What is proxy-compare?

The proxy-compare npm package is a utility for creating proxies that can be used to track changes in objects. It is particularly useful in state management scenarios where you need to detect changes in nested objects efficiently.

What are proxy-compare's main functionalities?

Create Proxies

This feature allows you to create a proxy for an object. Any changes made to the proxy will be tracked, which is useful for state management.

const { createProxy } = require('proxy-compare');

const state = { a: 1, b: { c: 2 } };
const proxyState = createProxy(state);

proxyState.a = 2; // This will be tracked
proxyState.b.c = 3; // This will also be tracked

Track Changes

This feature allows you to track changes made to the proxy and retrieve the untracked state. This is useful for comparing the current state with the previous state.

const { createProxy, getUntracked } = require('proxy-compare');

const state = { a: 1, b: { c: 2 } };
const proxyState = createProxy(state);

proxyState.a = 2;
const untrackedState = getUntracked(proxyState);
console.log(untrackedState); // { a: 2, b: { c: 2 } }

Deep Comparison

This feature allows you to perform a deep comparison between the proxy and the original state to check if any changes have been made.

const { isChanged } = require('proxy-compare');

const state = { a: 1, b: { c: 2 } };
const proxyState = createProxy(state);

proxyState.b.c = 3;
const hasChanged = isChanged(proxyState, state);
console.log(hasChanged); // true

Other packages similar to proxy-compare

Keywords

FAQs

Package last updated on 29 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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