-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from omgaz/upgrade
[major] upgrade deps and readme
- Loading branch information
Showing
12 changed files
with
810 additions
and
1,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
# Editors | ||
.vscode | ||
|
||
# Dependency directory | ||
# Commenting this out is preferred by some people, see | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- | ||
node_modules | ||
|
||
# Users Environment Variables | ||
.lock-wscript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- "8" | ||
addons: | ||
chrome: stable | ||
- "12" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,58 @@ | ||
js-diff | ||
======= | ||
<div align="center"> | ||
<img src="stuff/AppIcon-readme.png" height="200" /> | ||
<h1>diffler</h1> | ||
<p> | ||
<b>A recursive JSON comparison script for humans</b> | ||
</p> | ||
<br> | ||
<br> | ||
</div> | ||
|
||
[![Build Status](https://travis-ci.org/omgaz/js-diff.svg?branch=master)](https://travis-ci.org/omgaz/js-diff) | ||
## Motivation | ||
|
||
To compare JSON objects containing asset metadata for a digital library. Upon change of any metadata, we'd store these changes as an audit trail and email asset stakeholders for review and approval of the changes. | ||
|
||
## Dependencies | ||
|
||
diffler is written with Node v12 in mind. | ||
Tests depend on [Mocha](https://mochajs.org/). | ||
|
||
## Usage | ||
|
||
```bash | ||
npm install diffler | ||
``` | ||
|
||
A basic JavaScript object comparison script that will iterate, recursivly, through two JSON objects to compare differences. | ||
### Params | ||
|
||
This was built for a project in which I had a JSON object of user data that I cached on page load and compared against an edited version on save. I used this information to construct email summaries of changed behaviour as well as provide a detailed audit trail of actions. | ||
`obj1` and `obj2` are two JSON objects for comparison. | ||
|
||
Code | ||
---- | ||
Code can be found under `src` at [src/diff.js](src/diff.js). That's all you need to worry about and the code has no dependencies on any library. NodeJS and all the other files are purely for running tests. | ||
### Return | ||
|
||
Params | ||
------ | ||
`obj1` and `obj2` are two objects to be compared. | ||
If no difference: returns `{}` *(empty object)* | ||
|
||
Return | ||
------ | ||
Returns `false` if no differences are found. | ||
Returns an `object` if differences are found. The object will maintain path structure where the value fot he changed key/value pair is highlighted by from and to fields. | ||
If difference: A JSON object with preserved path structure. The resulting values will be an object with `from` and `to` fields. | ||
|
||
Example | ||
------- | ||
### Example | ||
|
||
var x = { name: "omgaz", location: "London" }; | ||
var y = { name: "omgaz", location: "Melbourne" }; | ||
```js | ||
const jsDiff = require('diffler'); | ||
|
||
getDiff(x, y); | ||
const before = { name: "omgaz", location: "London" }; | ||
const after = { name: "omgaz", location: "Melbourne" }; | ||
|
||
// Returns object | ||
{ | ||
location: { | ||
from: "London", | ||
to: "Melbourne" | ||
} | ||
} | ||
const difference = jsDiff(before, after); | ||
console.log(difference); // { location: { from: "London", to: "Melbourne" } } | ||
``` | ||
|
||
Tests | ||
----- | ||
|
||
[![Build Status](https://travis-ci.org/omgaz/js-diff.svg?branch=master)](https://travis-ci.org/omgaz/js-diff) | ||
|
||
If you'd like to run tests, check out the whole project. You'll need NodeJS installed. Tests use Karma and ChromeHeadless. | ||
If you'd like to run tests, check out the whole project. You'll need NodeJS installed. Tests use Mocha. | ||
|
||
npm install | ||
npm test | ||
```bash | ||
npm install | ||
npm test | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.