diff --git a/ext/npm-utils.js b/ext/npm-utils.js index 5f1c4e0b8..e6002294e 100644 --- a/ext/npm-utils.js +++ b/ext/npm-utils.js @@ -11,10 +11,36 @@ var slice = Array.prototype.slice; var npmModuleRegEx = /.+@.+\..+\..+#.+/; var conditionalModuleRegEx = /#\{[^\}]+\}|#\?.+$/; var gitUrlEx = /(git|http(s?)):\/\//; +var supportsSet = typeof Set === "function"; var utils = { - extend: function(d, s, deep){ + extend: function(d, s, deep, set){ var val; + + if(deep) { + if(!set) { + if(supportsSet) { + set = new Set(); + } else { + set = []; + } + } + + if(supportsSet) { + if(set.has(s)) { + return s; + } else { + set.add(s); + } + } else { + if(set.indexOf(s) !== -1) { + return s; + } else { + set.push(s); + } + } + } + for(var prop in s) { val = s[prop]; @@ -22,7 +48,7 @@ var utils = { if(utils.isArray(val)) { d[prop] = slice.call(val); } else if(utils.isObject(val)) { - d[prop] = utils.extend({}, val, deep); + d[prop] = utils.extend({}, val, deep, set); } else { d[prop] = s[prop]; } diff --git a/package.json b/package.json index 375c03a8c..09a0f42f2 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "saucelabs": "^1.3.0", "steal-env": "^1.0.0", "steal-es6-module-loader": "0.17.13", - "steal-npm": "1.0.2", + "steal-npm": "1.0.3", "steal-qunit": "^1.0.0", "system-bower": "stealjs/system-bower#v0.2.1", "system-live-reload": "1.5.3",