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

tree-changes

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree-changes

Get changes between two versions of data with similar shape

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
425K
decreased by-9.81%
Maintainers
1
Weekly downloads
 
Created

What is tree-changes?

The tree-changes npm package is a utility for detecting changes between two states of a JavaScript object. It helps in identifying added, updated, and removed properties, making it useful for state management and change detection in applications.

What are tree-changes's main functionalities?

Detect Added Properties

This feature allows you to detect properties that have been added to the new state compared to the previous state.

const TreeChanges = require('tree-changes');
const prevState = { a: 1 };
const nextState = { a: 1, b: 2 };
const changes = new TreeChanges(prevState, nextState);
console.log(changes.added()); // { b: 2 }

Detect Updated Properties

This feature allows you to detect properties that have been updated in the new state compared to the previous state.

const TreeChanges = require('tree-changes');
const prevState = { a: 1 };
const nextState = { a: 2 };
const changes = new TreeChanges(prevState, nextState);
console.log(changes.updated()); // { a: 2 }

Detect Removed Properties

This feature allows you to detect properties that have been removed from the new state compared to the previous state.

const TreeChanges = require('tree-changes');
const prevState = { a: 1, b: 2 };
const nextState = { a: 1 };
const changes = new TreeChanges(prevState, nextState);
console.log(changes.removed()); // { b: 2 }

Other packages similar to tree-changes

Keywords

FAQs

Package last updated on 18 Sep 2021

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