'use strict';


angular.module('streamium.peer', [])

.service('PeerJS', function(bitcore) {

  function getPeerJSConfig(config, index) {
    if (index >= config.peerServers.length) throw new Error('Invalid Server number');

    var ret = angular.copy(config.peerJS);
    bitcore.deps._.extend(ret, config.peerServers[index]);
    ret.index = index;
    return ret;
  }

  return {
    primary: getPeerJSConfig(config, 0),
    secondary: getPeerJSConfig(config, 1),
    get: function(index) {
      return getPeerJSConfig(config, index);
    }
  };

});

'use strict';


angular.module('streamium.peer', [])

.service('PeerJS', function() {

  function getPeerJSConfig(config, index) {
    if (index >= config.peerServers.length) throw new Error('Invalid Server number');

    var ret  = angular.copy(config.peerJS);
    ret.key  = config.peerServers[index].key;
    ret.host = config.peerServers[index].host;
    ret.port = config.peerServers[index].port;
    ret.index = index;
    return ret;
  }

  return {
    primary: getPeerJSConfig(config, 0),
    secondary: getPeerJSConfig(config, 1),
    get: function(index) {
      return getPeerJSConfig(config, index);
    }
  };

});

--- 
+++ 
@@ -3,15 +3,13 @@
 
 angular.module('streamium.peer', [])
 
-.service('PeerJS', function() {
+.service('PeerJS', function(bitcore) {
 
   function getPeerJSConfig(config, index) {
     if (index >= config.peerServers.length) throw new Error('Invalid Server number');
 
-    var ret  = angular.copy(config.peerJS);
-    ret.key  = config.peerServers[index].key;
-    ret.host = config.peerServers[index].host;
-    ret.port = config.peerServers[index].port;
+    var ret = angular.copy(config.peerJS);
+    bitcore.deps._.extend(ret, config.peerServers[index]);
     ret.index = index;
     return ret;
   }
Extend object; dont add undefined `keys`
