Sha256: aa202f3d28f0c05465e1cf94be18c4b3759c8c9f08c07821d7d4f9526f7e4116

Contents?: true

Size: 979 Bytes

Versions: 7

Compression:

Stored size: 979 Bytes

Contents

/*
---
 
script: Base.js
 
description: Speedy function that checks equality of objects (doing some nasty type assumption)
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin

extends: Core/Object

*/



Object.equals = function(one, another) {
  if (one == another) return true;
  if ((!one) ^ (!another)) return false;
  if (typeof one == 'undefined') return false;
  
  if ((one instanceof Array) || one.callee) {
    var j = one.length;
    if (j != another.length) return false;
    for (var i = 0; i < j; i++) if (!Object.equals(one[i], another[i])) return false;
    return true;
  } else if (one instanceof Color) {
    return (one.red == another.red) && (one.green == another.green) && (one.blue == another.blue) && (one.alpha == another.alpha)
  } else if (typeof one == 'object') {
    if (one.equals) return one.equals(another)
    for (var i in one) if (!Object.equals(one[i], another[i])) return false;
    return true;
  }
  return false;
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1.5 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1.4 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1.3 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1.2 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1.1 Packages/mootools-speedups/Source/Types/Object.js
lsd_rails-0.1 Packages/mootools-speedups/Source/Types/Object.js