GithubHelp home page GithubHelp logo

yj1438 / deep-diff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dispix/deep-diff

0.0 1.0 0.0 3.82 MB

Small library who deeply check for difference between two objects

JavaScript 100.00%

deep-diff's Introduction

Deep Diff

Build Status npm Coverage Status

Function returning an object representing the difference between two objects. The function is immutable-compliant as it does not affect the arguments.

Installation

npm install -S return-deep-diff

Usage

import deepDiff from 'return-deep-diff'

const objOne = {
  a: 1,
  b: {
    c: 2,
    d: 3
  },
  e: 4
}

const objTwo = {
  a: 1,
  b: {
    c: 2,
    d: 30,
    f: 50
  },
  e: 40
}

console.log(deepDiff(objOne, objTwo))
/*
returns:
  {
    b: {
      d: 30
    },
    e: 40
  }
*/

console.log(deepDiff(objOne, objTwo, true))
/*
returns:
  {
    b: {
      d: 30
      f: 50
    },
    e: 40
  }
*/

The two objects must share the exact same structure, which is defined by the first object. If a key is present in the second but not the first object, it will not be present in the diff object unless keepNewKeys equals true. The function does not mutate neither the first nor the second object.

deep-diff's People

Contributors

dispix avatar zeljic avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.