Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Gottox/node-objdiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flattr this git repo

ObjDiff

This node library implements a very simple diff algorithm for javascript/json objects.

An example diff object looks like:

> objdiff({a:2,c:1},{b:2,c:2})
{ a: 
   { '$changed': true,
     '-': 2 },
  c: 
   { '$changed': true,
     '-': 1,
     '+': 2 },
  b: 
   { '$changed': true,
     '+': 2 } }

every value, that has changed is represented by an object with the key-value pair $changed: true.

Installation

Node

# npm install objdiff

Browser

# git clone git://github.com/Gottox/node-objdiff.git
# cd node-objdiff
# make build

This compiles a browserbuild version to dist/objdiff

Usage

Node

var objdiff = require('objdiff').objdiff
objdiff({a:1}, {b:2});

Browser

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript" src="dist/objdiff.js"></script>
	</head>
	<body>
		<script type="text/javascript">
			var objdiff = ObjDiff.objdiff
			document.write(JSON.stringify(objdiff({a:1}, {b:2})));
		</script>
	</body>
</html>

About

Diffs two javascript objects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published