{"size": 1099, "ext": "js", "max_stars_repo_path": "lib/util.js", "max_stars_repo_name": "rtc-io/rtc-health", "max_stars_repo_stars_event_min_datetime": "2019-12-08T22:43:17.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-13T14:15:27.000Z", "max_issues_repo_path": "lib/util.js", "max_issues_repo_name": "rtc-io/rtc-health", "max_issues_repo_issues_event_min_datetime": "2015-08-07T03:25:24.000Z", "max_issues_repo_issues_event_max_datetime": "2016-11-24T05:58:51.000Z", "max_forks_repo_path": "lib/util.js", "max_forks_repo_name": "rtc-io/rtc-health", "max_forks_repo_forks_event_min_datetime": "2015-07-28T06:05:25.000Z", "max_forks_repo_forks_event_max_datetime": "2015-09-05T23:12:21.000Z"}
{"max_stars_count": 2, "max_issues_count": 9, "max_forks_count": 2, "avg_line_length": 26.1666666667, "max_line_length": 82, "alphanum_fraction": 0.71155596}
var humps = require('humps');

var STATUS_CONNECTING = 'connecting',
	STATUS_CONNECTED = 'connected',
	STATUS_DISCONNECTED = 'disconnected',
	STATUS_ERROR = 'error',
	STATUS_CLOSED = 'closed',
	STATUS_UNKNOWN = 'unknown';

var statusMappings = {
		'new': STATUS_CONNECTING,
		'checking': STATUS_CONNECTING,
		'connected': STATUS_CONNECTED,
		'completed': STATUS_CONNECTED,
		'failed': STATUS_ERROR,
		'disconnected': STATUS_DISCONNECTED,
		'closed': STATUS_CLOSED
	};

exports.connectionId = function(source, target) {
	return (source < target 
			? source + ':' + target 
			: target + ':' + source);
}

exports.toStatus = function(iceConnectionState) {
	if (!iceConnectionState) return STATUS_UNKNOWN;

	var status = statusMappings[iceConnectionState.toLowerCase()];
	return status || STATUS_UNKNOWN;
}

exports.standardizeKey = function(prefix, key) {
	if (!key) return key;
	var normalized = key;
	if (key.indexOf(prefix) === 0) {
		normalized = key.replace(prefix, '');
	}
	return humps.camelize(normalized);
}

exports.SIGNALLER_EVENTS = ['init', 'open', 'connected', 'disconnected', 'error'];