A little utility for testing equality
sudo npm install equality
git clone git://github.com/apeace/equality.git cd equality sudo npm install vows test/* --spec
var equality = ;// deepvar A = a: b: 'c' d: e: 'f'B = a: b: 'c' d: e: 'f'C = x: 10 y: e: 'f' ;equality; // ==> trueequality; // ==> falseequality; // ==> true// deeper!var X = a: A b: B c: CY = a: A b: B c: CZ = a: C b: A c: B ;equality; // ==> trueequality; // ==> falseequality; // ==> true// whoa...var D = 1 2 3 1E = 1 1 3 2F = 6 7 8 ;equality; // ==> trueequality; // ==> false
deep( obj1, obj2 )tests for deep equality between two objects
members( arr1, arr2 )tests whether two arrays have the same members, regardless of order
hash( obj )returns a hash string that uniquely identifies the given object (based on its value)
type( obj1, obj2 )tests whether the two objects have the same type
Just released this real quick because I wanted it for a project. Planning on adding some more interesting methods and lots more tests. Feel free to pull request, of course.
Copyright (c) 2011 Andrew Peace
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.