From 2610bb551308598d4d8e5bce0466f283075dfdaa Mon Sep 17 00:00:00 2001 From: Ivo Georgiev Date: Tue, 15 Jan 2013 02:55:01 +0000 Subject: [PATCH] Fix array check for node-webkit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This seems to be a very weird bug, but when using ejdb with node-webkit, .constructor === Array returns false for actual arrays. This is because node-webkit runs ejdb as a node  module in a different JavaScript context (WebKit context), so there are actually two unique objects that represent any constructor (one of each scope). So instead of comparing if .constructor references to the same object as "Array", we just check if the name of the constructor is "Array". --- node/ejdb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/ejdb.js b/node/ejdb.js index 0a780ea..fb54cdc 100644 --- a/node/ejdb.js +++ b/node/ejdb.js @@ -163,7 +163,7 @@ EJDB.prototype.save = function(cname, jsarr, opts, cb) { if (!jsarr) { return []; } - if (jsarr.constructor !== Array) { + if (! (jsarr.constructor.name == "Array")) { jsarr = [jsarr]; } if (typeof opts == "function") { -- 2.7.4