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

just-diff-apply

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-diff-apply

Apply a diff to an object. Optionally supports jsonPatch protocol

  • 5.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
decreased by-12.06%
Maintainers
1
Weekly downloads
 
Created

What is just-diff-apply?

The npm package 'just-diff-apply' is a utility that allows users to apply differences between objects or arrays. It is typically used in scenarios where changes need to be tracked and applied, such as in state management or data synchronization.

What are just-diff-apply's main functionalities?

Applying differences to objects

This feature allows you to apply a set of differences to an object. In the provided code, a difference is applied to change the value of 'a' from 3 to 4.

const diffApply = require('just-diff-apply');
const obj = {a: 3, b: 5};
const diff = [{op: 'replace', path: ['a'], value: 4}];
diffApply(obj, diff);
console.log(obj); // {a: 4, b: 5}

Applying differences to arrays

This feature enables the application of differences to arrays. In the example, an element with value 5 is added at index 1.

const diffApply = require('just-diff-apply');
const arr = [1, 2, 3];
const diff = [{op: 'add', path: [1], value: 5}];
diffApply(arr, diff);
console.log(arr); // [1, 5, 2, 3]

Other packages similar to just-diff-apply

Keywords

FAQs

Package last updated on 17 Dec 2022

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