diff --git a/README.markdown b/README.markdown index 69a7334..151a3ed 100644 --- a/README.markdown +++ b/README.markdown @@ -156,6 +156,49 @@ with the return value of `fn(acc, node)`. If `acc` isn't specified, `acc` is set to the root object for the first step and the root element is skipped. +.deepEqual(obj) +--------------- + +Returns a boolean, whether the instance value is equal to the supplied object +along a deep traversal using some opinionated choices. + +Some notes: + +* RegExps are equal if their .toString()s match, but not functions since +functions can close over different variables. + +* Date instances are compared using `.getTime()` just like `assert.deepEqual()`. + +* Circular references must refer to the same paths within the data structure for +both objects. For instance, in this snippet: + +````javascript +var a = [1]; +a.push(a); // a = [ 1, *a ] + +var b = [1]; +b.push(a); // b = [ 1, [ 1, *a ] ] +```` + +`a` is not the same as `b` since even though the expansion is the same, the +circular references in each refer to different paths into the data structure. + +However, in: + +````javascript +var c = [1]; +c.push(c); // c = [ 1, *c ]; +```` + +`c` is equal to `a` in a `deepEqual()` because they have the same terminal node +structure. + +* Arguments objects are not arrays and neither are they the same as regular +objects. + +* Instances created with `new` of String, Boolean, and Number types are never +equal to the native versions. + .paths() -------- diff --git a/package.json b/package.json index bd49ec8..3d21698 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "traverse", - "version" : "0.3.5", + "version" : "0.3.6", "description" : "Traverse and transform objects by visiting every node on a recursive walk", "author" : "James Halliday", "license" : "MIT/X11",