Comparing version 0.0.10 to 0.0.11
@@ -156,3 +156,3 @@ (function (exports) { | ||
for(var i in derived) { | ||
if(!base[i] || cmp.ne(derived[i], base[i])) { | ||
if(!base.hasOwnProperty(i) || cmp.ne(derived[i], base[i])) { | ||
return false; | ||
@@ -159,0 +159,0 @@ } |
(function(e){var t={eq:"equal",ne:"notEqual",gt:"greaterThan",ge:"greaterThanOrEqual",lt:"lessThan",le:"lessThanOrEqual",id:"identical",eqs:"equalByStructure",nes:"notEqualByStructure",gts:"greaterThanByStructure",ges:"greaterThanOrEqualByStructure",lts:"lessThanByStructure",les:"lessThanOrEqualByStructure"},n={eq:function(e,t){return typeof e=="function"&&typeof t=="function"&&(e=e.toString(),t=t.toString()),typeof e=="object"&&typeof t=="object"&&e&&t?r(e,t)&&r(t,e):e===t},eqs:function(e,t){return e&&!t||!e&&t?!1:!e&&!t?!0:i(e,t)&&i(t,e)},ne:function(e,t){return!this.eq(e,t)},nes:function(e,t){return!this.eqs(e,t)},gt:function(e,t){return typeof e=="function"||typeof t=="function"?!1:typeof e=="object"&&typeof t=="object"&&e&&t?r(t,e)&&!r(e,t):typeof e=="object"&&!t||typeof t=="object"&&!e?!1:e>t},gts:function(e,t){return e&&!t?!0:e?i(t,e)&&!i(e,t):!1},ge:function(e,t){return this.gt(e,t)||this.eq(e,t)},ges:function(e,t){return this.gts(e,t)||this.eqs(e,t)},lt:function(e,t){return typeof e=="function"||typeof t=="function"?!1:typeof e=="object"&&typeof t=="object"&&e&&t?r(e,t)&&!r(t,e):typeof e=="object"&&!t||typeof t=="object"&&!e?!1:e<t},lts:function(e,t){return!e&&t?!0:t?i(e,t)&&!i(t,e):!1},le:function(e,t){return this.lt(e,t)||this.eq(e,t)},les:function(e,t){return this.lts(e,t)||this.eqs(e,t)},id:function(e,t){return typeof e=="function"&&typeof t=="function"||typeof e=="object"&&typeof t=="object"?e===t:this.eq(e,t)}},r=function(e,t){for(var r in e)if(!t[r]||n.ne(e[r],t[r]))return!1;return!0},i=function(e,t){for(var n in e)if(typeof t[n]!=typeof e[n])return!1;return!0},s=function(e,t){return function(){return e.apply(t,arguments)}},o=function(e,t){return function(){var n=[e].concat(Array.prototype.slice.call(arguments,0));return t.apply(this,n)}},u=function(e){return e===null?e:typeof e!="object"||e.constructor!==Number&&e.constructor!==String&&e.constructor!==Boolean?e:e.valueOf()},a=function(e,t,n){return t=u(t),n=u(n),e(t,n)},f=function(e,t,n){return typeof t!="object"||typeof n!="object"?!1:t&&n&&(t.constructor===Array||n.constructor===Array)?!1:e(t,n)},l=function(e,t){return o(s(e,n),t)};for(var c in n)n.hasOwnProperty(c)&&(c.length===3?e[c]=e[t[c]]=l(n[c],f):e[c]=e[t[c]]=l(n[c],a))})(typeof exports!="undefined"?exports:window.cmp={}) | ||
(function(e){var t={eq:"equal",ne:"notEqual",gt:"greaterThan",ge:"greaterThanOrEqual",lt:"lessThan",le:"lessThanOrEqual",id:"identical",eqs:"equalByStructure",nes:"notEqualByStructure",gts:"greaterThanByStructure",ges:"greaterThanOrEqualByStructure",lts:"lessThanByStructure",les:"lessThanOrEqualByStructure"},n={eq:function(e,t){return typeof e=="function"&&typeof t=="function"&&(e=e.toString(),t=t.toString()),typeof e=="object"&&typeof t=="object"&&e&&t?r(e,t)&&r(t,e):e===t},eqs:function(e,t){return e&&!t||!e&&t?!1:!e&&!t?!0:i(e,t)&&i(t,e)},ne:function(e,t){return!this.eq(e,t)},nes:function(e,t){return!this.eqs(e,t)},gt:function(e,t){return typeof e=="function"||typeof t=="function"?!1:typeof e=="object"&&typeof t=="object"&&e&&t?r(t,e)&&!r(e,t):typeof e=="object"&&!t||typeof t=="object"&&!e?!1:e>t},gts:function(e,t){return e&&!t?!0:e?i(t,e)&&!i(e,t):!1},ge:function(e,t){return this.gt(e,t)||this.eq(e,t)},ges:function(e,t){return this.gts(e,t)||this.eqs(e,t)},lt:function(e,t){return typeof e=="function"||typeof t=="function"?!1:typeof e=="object"&&typeof t=="object"&&e&&t?r(e,t)&&!r(t,e):typeof e=="object"&&!t||typeof t=="object"&&!e?!1:e<t},lts:function(e,t){return!e&&t?!0:t?i(e,t)&&!i(t,e):!1},le:function(e,t){return this.lt(e,t)||this.eq(e,t)},les:function(e,t){return this.lts(e,t)||this.eqs(e,t)},id:function(e,t){return typeof e=="function"&&typeof t=="function"||typeof e=="object"&&typeof t=="object"?e===t:this.eq(e,t)}},r=function(e,t){for(var r in e)if(!t.hasOwnProperty(r)||n.ne(e[r],t[r]))return!1;return!0},i=function(e,t){for(var n in e)if(typeof t[n]!=typeof e[n])return!1;return!0},s=function(e,t){return function(){return e.apply(t,arguments)}},o=function(e,t){return function(){var n=[e].concat(Array.prototype.slice.call(arguments,0));return t.apply(this,n)}},u=function(e){return e===null?e:typeof e!="object"||e.constructor!==Number&&e.constructor!==String&&e.constructor!==Boolean?e:e.valueOf()},a=function(e,t,n){return t=u(t),n=u(n),e(t,n)},f=function(e,t,n){return typeof t!="object"||typeof n!="object"?!1:t&&n&&(t.constructor===Array||n.constructor===Array)?!1:e(t,n)},l=function(e,t){return o(s(e,n),t)};for(var c in n)n.hasOwnProperty(c)&&(c.length===3?e[c]=e[t[c]]=l(n[c],f):e[c]=e[t[c]]=l(n[c],a))})(typeof exports!="undefined"?exports:window.cmp={}) |
{ | ||
"VERSION": "0.0.10", | ||
"VERSION": "0.0.11", | ||
"JAVASCRIPT": { | ||
@@ -4,0 +4,0 @@ "compare": [ "./lib/index.js" ], |
@@ -156,3 +156,3 @@ (function (exports) { | ||
for(var i in derived) { | ||
if(!base[i] || cmp.ne(derived[i], base[i])) { | ||
if(!base.hasOwnProperty(i) || cmp.ne(derived[i], base[i])) { | ||
return false; | ||
@@ -159,0 +159,0 @@ } |
{ | ||
"name": "comparejs", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Implementing the comparison operators eq, ne, gt, ge, lt and le in JavaScript for use with Node.js and the browser.", | ||
@@ -5,0 +5,0 @@ "author": "Golo Roden <webmaster@goloroden.de>", |
@@ -56,3 +56,3 @@ # comparejs | ||
- Supports comparison by equality and identity, depending on what makes sense. | ||
- Developed using TDD and backed up by more than 890 unit tests. | ||
- Developed using TDD and backed up by more than 930 unit tests. | ||
@@ -59,0 +59,0 @@ ## Basic usage |
@@ -13,2 +13,5 @@ var cmp = require('../lib/index'), | ||
Q1 = new Object(), | ||
r1 = { foo: '' }, | ||
r2 = { foo: '' }, | ||
s1 = { foo: null }, | ||
empty = {}, | ||
@@ -29,2 +32,3 @@ Empty = new Object(); | ||
test('null x null' , function () { cmp.eq(null, null).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.eq( r1, r2).should.equal(true); }); | ||
}); | ||
@@ -41,2 +45,5 @@ | ||
test('null x Object()' , function () { cmp.eq(null, O1).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.eq( o1, r1).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.eq( r1, o1).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.eq( r1, s1).should.equal(false); }); | ||
}); | ||
@@ -52,2 +59,3 @@ }); | ||
test('null x null' , function () { cmp.eqs(null, null).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.eqs( r1, r2).should.equal(true); }); | ||
}); | ||
@@ -64,2 +72,5 @@ | ||
test('null x Object()' , function () { cmp.eqs(null, O1).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.eqs( q1, r1).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.eqs( r1, q1).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.eqs( r1, s1).should.equal(false); }); | ||
}); | ||
@@ -75,2 +86,3 @@ }); | ||
test('null x null' , function () { cmp.ne(null, null).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.ne( r1, r2).should.equal(false); }); | ||
}); | ||
@@ -87,2 +99,5 @@ | ||
test('null x Object()' , function () { cmp.ne(null, O1).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.ne( r1, s1).should.equal(true); }); | ||
test('object x false' , function () { cmp.ne( o1, r1).should.equal(true); }); | ||
test('falsy x object' , function () { cmp.ne( r1, o1).should.equal(true); }); | ||
}); | ||
@@ -98,2 +113,5 @@ }); | ||
test('null x null' , function () { cmp.nes(null, null).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.nes( r1, r2).should.equal(false); }); | ||
test('object x false' , function () { cmp.nes( o1, r1).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.nes( r1, o1).should.equal(false); }); | ||
}); | ||
@@ -110,2 +128,3 @@ | ||
test('null x Object()' , function () { cmp.nes(null, O1).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.nes( r1, s1).should.equal(true); }); | ||
}); | ||
@@ -120,2 +139,3 @@ }); | ||
test('Object() x Object()', function () { cmp.gt(O1, Empty).should.equal(true); }); | ||
test('falsy x object' , function () { cmp.gt(r1, empty).should.equal(true); }); | ||
}); | ||
@@ -129,2 +149,3 @@ | ||
test('null x null' , function () { cmp.gt(null, null).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.gt( r1, r1).should.equal(false); }); | ||
}); | ||
@@ -141,2 +162,3 @@ | ||
test('null x Object()' , function () { cmp.gt(null, O1).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.gt( r1, r2).should.equal(false); }); | ||
}); | ||
@@ -149,2 +171,3 @@ | ||
test('Object() x Object()', function () { cmp.gt(Empty, O1).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.gt(empty, r1).should.equal(false); }); | ||
}); | ||
@@ -194,2 +217,3 @@ }); | ||
test('Object() x Object()', function () { cmp.ge(O1, Empty).should.equal(true); }); | ||
test('falsy x object' , function () { cmp.ge(r1, empty).should.equal(true); }); | ||
}); | ||
@@ -203,2 +227,3 @@ | ||
test('null x null' , function () { cmp.ge(null, null).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.ge( r1, r1).should.equal(true); }); | ||
}); | ||
@@ -215,2 +240,6 @@ | ||
test('null x Object()' , function () { cmp.ge(null, O1).should.equal(false); }); | ||
test('null x falsy' , function () { cmp.ge(null, r1).should.equal(false); }); | ||
test('falsy x null' , function () { cmp.ge( r1, null).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.ge( o1, r1).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.ge( r1, o1).should.equal(false); }); | ||
}); | ||
@@ -223,2 +252,3 @@ | ||
test('Object() x Object()', function () { cmp.ge(Empty, O1).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.ge(empty, r1).should.equal(false); }); | ||
}); | ||
@@ -268,2 +298,3 @@ }); | ||
test('Object() x Object()', function () { cmp.lt(O1, Empty).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.lt(r1, empty).should.equal(false); }); | ||
}); | ||
@@ -277,2 +308,3 @@ | ||
test('null x null' , function () { cmp.lt(null, null).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.lt( r1, r1).should.equal(false); }); | ||
}); | ||
@@ -289,2 +321,3 @@ | ||
test('null x Object()' , function () { cmp.lt(null, O1).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.lt( r1, r2).should.equal(false); }); | ||
}); | ||
@@ -297,2 +330,3 @@ | ||
test('Object() x Object()', function () { cmp.lt(Empty, O1).should.equal(true); }); | ||
test('object x falsy' , function () { cmp.lt(empty, r1).should.equal(true); }); | ||
}); | ||
@@ -342,2 +376,3 @@ }); | ||
test('Object() x Object()', function () { cmp.le(O1, Empty).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.le(r1, empty).should.equal(false); }); | ||
}); | ||
@@ -351,2 +386,3 @@ | ||
test('null x null' , function () { cmp.le(null, null).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.le( r1, r1).should.equal(true); }); | ||
}); | ||
@@ -363,2 +399,6 @@ | ||
test('null x Object()' , function () { cmp.le(null, O1).should.equal(false); }); | ||
test('null x falsy' , function () { cmp.le(null, r1).should.equal(false); }); | ||
test('falsy x null' , function () { cmp.le( r1, null).should.equal(false); }); | ||
test('object x falsy' , function () { cmp.le( o1, r1).should.equal(false); }); | ||
test('falsy x object' , function () { cmp.le( r1, o1).should.equal(false); }); | ||
}); | ||
@@ -371,2 +411,3 @@ | ||
test('Object() x Object()', function () { cmp.le(Empty, O1).should.equal(true); }); | ||
test('object x falsy' , function () { cmp.le(empty, r1).should.equal(true); }); | ||
}); | ||
@@ -415,2 +456,3 @@ }); | ||
test('null x null' , function () { cmp.id(null, null).should.equal(true); }); | ||
test('falsy x falsy' , function () { cmp.id( r1, r1).should.equal(true); }); | ||
}); | ||
@@ -423,4 +465,5 @@ | ||
test('Object() x Object()', function () { cmp.id( O1, O2).should.equal(false); }); | ||
test('falsy x falsy' , function () { cmp.id( r1, r2).should.equal(false); }); | ||
}); | ||
}); | ||
}); |
154053
27
2547