From b1896e37376b6276ed20bf453d55a49c22120c12 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 1 Apr 2016 10:12:15 +0100 Subject: [PATCH] Fix RED.util.compareObjects for Function created objects and Buffers --- red/runtime/util.js | 34 +++++++++++++++++++++++++++++----- test/red/runtime/util_spec.js | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/red/runtime/util.js b/red/runtime/util.js index 9e96bc4b6..8c51f2cda 100644 --- a/red/runtime/util.js +++ b/red/runtime/util.js @@ -62,31 +62,55 @@ function cloneMessage(msg) { } function compareObjects(obj1,obj2) { + var i; if (obj1 === obj2) { return true; } if (obj1 == null || obj2 == null) { return false; } - if (!(obj1 instanceof Object) && !(obj2 instanceof Object)) { - return false; - } + var isArray1 = Array.isArray(obj1); var isArray2 = Array.isArray(obj2); if (isArray1 != isArray2) { return false; } if (isArray1 && isArray2) { - if (obj1.length != obj2.length) { + if (obj1.length !== obj2.length) { return false; } - for (var i=0;i