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

jsdiff

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdiff

diff objects

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
decreased by-4.74%
Maintainers
1
Weekly downloads
 
Created
Source

jsdiff

diff values

Installation

npm install jsdiff

API

diff(a, b)

returns an object with truthy values for stuff that changed.

diff({ a: 'foo' }, {}) -> { a: true }

diff({ a: 'foo' }, { a: 'bar' }) -> { a: true }

diff({ a: 'foo' }, { b: 'bar' }) -> { a: true, b: true }

diff({}, { b: 'foo' }) -> { b: true }

diff({ a: { b: 'foo'} }, { b: 'bar' }) -> { a: { b: true }, b: true }

diff([1, 2, 3], [1, 2, 4]) -> [ , , true ]

diff.patch(d, b, model)

patch up a model using a diff.

var a = { a: 'foo' }
  , b = { b: 'bar', c: { deep: 'stuff' } }
diff.patch(diff(a, b), b,
  { set: console.log.bind(console, 'set')
  , delete: console.log.bind(console, 'delete')
  })

output:

delete [ 'a' ]
set [ 'b' ] bar
set [ 'c', 'deep' ] stuff

Keywords

FAQs

Package last updated on 23 Oct 2014

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