|
|
@ -22,16 +22,19 @@ Network.prototype.toString = function toString() { |
|
|
|
* @member Networks#get |
|
|
|
* Retrieves the network associated with a magic number or string. |
|
|
|
* @param {string|number|Network} arg |
|
|
|
* @param {string} key - if set, only check if the magic number associated with this name matches |
|
|
|
* @param {string|Array} keys - if set, only check if the magic number associated with this name matches |
|
|
|
* @return Network |
|
|
|
*/ |
|
|
|
function getNetwork(arg, key) { |
|
|
|
function getNetwork(arg, keys) { |
|
|
|
if (~networks.indexOf(arg)) { |
|
|
|
return arg; |
|
|
|
} |
|
|
|
if (key) { |
|
|
|
if (keys) { |
|
|
|
if (!_.isArray(keys)) { |
|
|
|
keys = [keys]; |
|
|
|
} |
|
|
|
for (var index in networks) { |
|
|
|
if (networks[index][key] === arg) { |
|
|
|
if (_.any(keys, function(key) { return networks[index][key] === arg; })) { |
|
|
|
return networks[index]; |
|
|
|
} |
|
|
|
} |
|
|
|