{"bugs":{"url":"https://github.com/flitbit/diff/issues"},"dist":{"shasum":"0b14ddc811810a3269e50caab3327a30a4f3bfac","tarball":"https://registry.npmjs.org/deep-diff/-/deep-diff-1.0.0-pre.1.tgz","fileCount":30,"integrity":"sha512-c2FSkXgp5ACsNURUfiuRkn4Y4Xn0XRK8YUcjL49qCBFGgMSUnMDwBt1z73rE3wOVfcRB2gsW5L0LROsraolBKw==","signatures":[{"sig":"MEUCIQDpd+eBKhmpRXqQvt/CNPE60DYbeX9C1UbKeL7g8NAmJgIgH9ZFFfB49b0guIZdVJzK88NkO0kW5L8XKoSwxaGT+Ak=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":539168},"main":"./index.js","name":"deep-diff","author":{"name":"Phillip Clark","email":"phillip@flitbit.com"},"readme":"# deep-diff\n\n[![Build Status](https://travis-ci.org/flitbit/diff.png?branch=master)](https://travis-ci.org/flitbit/diff)\n\n[![NPM](https://nodei.co/npm/deep-diff.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-diff/)\n\n**deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects.\n\n## Features\n\n* Get the structural differences between two objects.\n* Observe the structural differences between two objects.\n* When structural differences represent change, apply change from one object to another.\n* When structural differences represent change, selectively apply change from one object to another.\n\n## ChangeLog\n\n## Installation\n\n```bash\nnpm install deep-diff\n```\n\n## Tests\n\nTests use [mocha](http://mochajs.org/) and [expect.js](https://github.com/LearnBoost/expect.js/), so if you clone the [github repository](https://github.com/flitbit/json-ptr) you'll need to run:\n\n```bash\nnpm install\n```\n\n... followed by ...\n\n```bash\nnpm test\n```\n\n... or ...\n\n```bash\nmocha -R spec\n```\n\n### Importing\n\n#### nodejs\n\n```javascript\nvar diff = require('deep-diff')\n// or:\n// const diff = require('deep-diff');\n// const { diff } = require('deep-diff');\n// or:\n// const DeepDiff = require('deep-diff');\n// const { DeepDiff } = require('deep-diff');\n// es6+:\n// import diff from 'deep-diff';\n// import { diff } from 'deep-diff';\n// es6+:\n// import DeepDiff from 'deep-diff';\n// import { DeepDiff } from 'deep-diff';\n```\n\n#### browser\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/deep-diff@1/dist/deep-diff.min.js\"></script>\n```\n\n> In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namespace you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`.\n\n## Simple Examples\n\nIn order to describe differences, change revolves around an `origin` object. For consistency, the `origin` object is always the operand on the `left-hand-side` of operations. The `comparand`, which may contain changes, is always on the `right-hand-side` of operations.\n\n``` javascript\nvar diff = require('deep-diff').diff;\n\nvar lhs = {\n\tname: 'my object',\n\tdescription: 'it\\'s an object!',\n\tdetails: {\n\t\tit: 'has',\n\t\tan: 'array',\n\t\twith: ['a', 'few', 'elements']\n\t}\n};\n\nvar rhs = {\n\tname: 'updated object',\n\tdescription: 'it\\'s an object!',\n\tdetails: {\n\t\tit: 'has',\n\t\tan: 'array',\n\t\twith: ['a', 'few', 'more', 'elements', { than: 'before' }]\n\t}\n};\n\nvar differences = diff(lhs, rhs);\n```\n\n*up to v 0.1.7* The code snippet above would result in the following structure describing the differences:\n\n``` javascript\n// Versions < 0.2.0\n[ { kind: 'E',\n    path: [ 'name' ],\n    lhs: 'my object',\n    rhs: 'updated object' },\n  { kind: 'A',\n    path: [ 'details', 'with' ],\n    index: 2,\n    item: { kind: 'E', path: [], lhs: 'elements', rhs: 'more' } },\n  { kind: 'A',\n    path: [ 'details', 'with' ],\n    index: 3,\n    item: { kind: 'N', rhs: 'elements' } },\n  { kind: 'A',\n    path: [ 'details', 'with' ],\n    index: 4,\n    item: { kind: 'N', rhs: { than: 'before' } } } ]\n```\n\n*v 0.2.0 and above* The code snippet above would result in the following structure describing the differences:\n\n``` javascript\n[ { kind: 'E',\n    path: [ 'name' ],\n    lhs: 'my object',\n    rhs: 'updated object' },\n  { kind: 'E',\n    path: [ 'details', 'with', 2 ],\n \t\tlhs: 'elements',\n \t\trhs: 'more' },\n  { kind: 'A',\n    path: [ 'details', 'with' ],\n    index: 3,\n    item: { kind: 'N', rhs: 'elements' } },\n  { kind: 'A',\n    path: [ 'details', 'with' ],\n    index: 4,\n    item: { kind: 'N', rhs: { than: 'before' } } } ]\n```\n\n### Differences\n\nDifferences are reported as one or more change records. Change records have the following structure:\n\n* `kind` - indicates the kind of change; will be one of the following:\n  * `N` - indicates a newly added property/element\n  * `D` - indicates a property/element was deleted\n  * `E` - indicates a property/element was edited\n  * `A` - indicates a change occurred within an array\n* `path` - the property path (from the left-hand-side root)\n* `lhs` - the value on the left-hand-side of the comparison (undefined if kind === 'N')\n* `rhs` - the value on the right-hand-side of the comparison (undefined if kind === 'D')\n* `index` - when kind === 'A', indicates the array index where the change occurred\n* `item` - when kind === 'A', contains a nested change record indicating the change that occurred at the array index\n\nChange records are generated for all structural differences between `origin` and `comparand`. The methods only consider an object's own properties and array elements; those inherited from an object's prototype chain are not considered.\n\nChanges to arrays are recorded simplistically. We care most about the shape of the structure; therefore we don't take the time to determine if an object moved from one slot in the array to another. Instead, we only record the structural\ndifferences. If the structural differences are applied from the `comparand` to the `origin` then the two objects will compare as \"deep equal\" using most `isEqual` implementations such as found in [lodash](https://github.com/bestiejs/lodash) or [underscore](http://underscorejs.org/).\n\n### Changes\n\nWhen two objects differ, you can observe the differences as they are calculated and selectively apply those changes to the origin object (left-hand-side).\n\n``` javascript\nvar observableDiff = require('deep-diff').observableDiff,\napplyChange        = require('deep-diff').applyChange;\n\nvar lhs = {\n\tname: 'my object',\n\tdescription: 'it\\'s an object!',\n\tdetails: {\n\t\tit: 'has',\n\t\tan: 'array',\n\t\twith: ['a', 'few', 'elements']\n\t}\n};\n\nvar rhs = {\n\tname: 'updated object',\n\tdescription: 'it\\'s an object!',\n\tdetails: {\n\t\tit: 'has',\n\t\tan: 'array',\n\t\twith: ['a', 'few', 'more', 'elements', { than: 'before' }]\n\t}\n};\n\nobservableDiff(lhs, rhs, function (d) {\n\t// Apply all changes except those to the 'name' property...\n\tif (d.path.length !== 1 || d.path.join('.') !== 'name') {\n\t\tapplyChange(lhs, rhs, d);\n\t}\n});\n```\n\n## API Documentation\n\nA standard import of `var diff = require('deep-diff')` is assumed in all of the code examples. The import results in an object having the following public properties:\n\n* `diff(lhs, rhs, prefilter, acc)` &mdash; calculates the differences between two objects, optionally prefiltering elements for comparison, and optionally using the specified accumulator.\n* `observableDiff(lhs, rhs, observer, prefilter)` &mdash; calculates the differences between two objects and reports each to an observer function, optionally, prefiltering elements for comparison.\n* `applyDiff(target, source, filter)` &mdash; applies any structural differences from a source object to a target object, optionally filtering each difference.\n* `applyChange(target, source, change)` &mdash; applies a single change record to a target object. NOTE: `source` is unused and may be removed.\n* `revertChange(target, source, change)` reverts a single change record to a target object. NOTE: `source` is unused and may be removed.\n\n### `diff`\n\nThe `diff` function calculates the difference between two objects.\n\n**Arguments**\n\n* `lhs` - the left-hand operand; the origin object.\n* `rhs` - the right-hand operand; the object being compared structurally with the origin object.\n* `prefilter` - an optional function that determines whether difference analysis should continue down the object graph.\n* `acc` - an optional accumulator/array (requirement is that it have a `push` function). Each difference is pushed to the specified accumulator.\n\n#### Pre-filtering Object Properties\n\nThe `prefilter`'s signature should be `function(path, key)` and it should return a truthy value for any `path`-`key` combination that should be filtered. If filtered, the difference analysis does no further analysis of on the identified object-property path.\n\n## Contributing\n\nWhen contributing, keep in mind that it is an objective of `deep-diff` to have no package dependencies. This may change in the future, but for now, no-dependencies.\n\nPlease run the unit tests before submitting your PR: `npm test`. Hopefully your PR includes additional unit tests to illustrate your change/modification!\n\nWhen you run `npm test`, linting will be performed and any linting errors will fail the tests... this includes code formatting.\n\n> Thanks to all those who have contributed so far!\n","gitHead":"c266dc9873ba6da7aa544527f96a7606100d412b","license":"MIT","scripts":{"ci":"mocha --reporter mocha-junit-reporter test/**/*.js","lint":"eslint index.js test","test":"mocha test/**/*.js","clean":"rimraf dist && mkdir dist","preci":"npm run lint","pretest":"npm run lint","release":"uglifyjs -c -m -o dist/deep-diff.min.js --source-map -r '$,require,exports,self,module,define' index.js","prerelease":"npm run clean && npm run test","preversion":"npm run release","test:watch":"nodemon --ext js,json --ignore dist/ --exec 'npm test'","postversion":"git push && git push --tags"},"_npmUser":{"name":"flitbit","email":"phillip@flitbit.com"},"homepage":"https://github.com/flitbit/diff#readme","keywords":["diff","difference","compare","change-tracking"],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git://github.com/flitbit/diff.git","type":"git"},"_npmVersion":"5.6.0","description":"Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.","directories":{},"maintainers":[{"name":"flitbit","email":"phillip@flitbit.com"}],"_nodeVersion":"8.9.4","contributors":[{"name":"Simen Bekkhus","email":"sbekkhus91@gmail.com"},{"name":"Paul Pflugradt","email":"paulpflugradt@googlemail.com"},{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"Nicholas Calugar","email":"njcalugar@gmail.com"},{"name":"Yandell","email":"hyandell@amazon.com"},{"name":"Thiago Santos","email":"thia.mdossantos@gmail.com"},{"name":"Steve Mao","email":"maochenyan@gmail.com"},{"name":"Mats Bryntse","email":"mats.dev@bryntum.com"},{"name":"Phillip Clark","email":"pclark@leisurelink.com"},{"name":"ZauberNerd","email":"zaubernerd@zaubernerd.de"},{"name":"ravishivt","email":"javishi@gmail.com"},{"name":"Daniel Spangler","email":"daniel.spangler@gmail.com"},{"name":"Sam Beran","email":"sberan@gmail.com"},{"name":"Thomas de Barochez","email":"thomas.barochez+github@gmail.com"},{"name":"Morton Fox","email":"github@qslw.com"},{"name":"Amila Welihinda","email":"amilajack@users.noreply.github.com"},{"name":"Will Biddy","email":"willbiddy@gmail.com"},{"name":"icesoar","email":"icesoar@hotmail.com"},{"name":"Serkan Serttop","email":"serkanserttop@yahoo.com"},{"name":"orlando","email":"operri@opentable.com"},{"name":"Tom MacWright","email":"tmcw@users.noreply.github.com"},{"name":"Denning","email":"denningj@amazon.com"},{"name":"Dan Drinkard","email":"dan.drinkard@gmail.com"},{"name":"Elad Efrat","email":"elad@iNNU.ORG"},{"name":"caasi Huang","email":"caasi.igd@gmail.com"},{"name":"Tom Ashworth","email":"tashworth@twitter.com"}],"_hasShrinkwrap":false,"readmeFilename":"Readme.md","devDependencies":{"json":"^9.0.6","mocha":"^5.0.1","eslint":"^4.18.1","rimraf":"^2.6.2","nodemon":"^1.15.1","bluebird":"^3.5.1","expect.js":"^0.3.1","uglify-js":"^3.3.12","deep-equal":"^1.0.1","eslint-plugin-mocha":"^4.11.0","mocha-junit-reporter":"^1.17.0"},"_npmOperationalInternal":{"tmp":"tmp/deep-diff_1.0.0-pre.1_1519599448466_0.9559632552666177","host":"s3://npm-registry-packages"},"_id":"deep-diff@1.0.0-pre.1","version":"1.0.0-pre.1"}