{"size": 2537, "ext": "js", "max_stars_repo_path": "src/utils/platform.js", "max_stars_repo_name": "justinboneh/ftree", "max_stars_repo_stars_event_min_datetime": "2017-01-10T07:12:27.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-24T11:18:51.000Z", "max_issues_repo_path": "src/utils/platform.js", "max_issues_repo_name": "justinboneh/ftree", "max_issues_repo_issues_event_min_datetime": "2016-12-08T04:27:11.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-27T19:52:31.000Z", "max_forks_repo_path": "src/utils/platform.js", "max_forks_repo_name": "justinboneh/ftree", "max_forks_repo_forks_event_min_datetime": "2016-12-08T07:53:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-13T14:28:48.000Z"}
{"max_stars_count": 5, "max_issues_count": 19, "max_forks_count": 5, "avg_line_length": 21.5, "max_line_length": 71, "alphanum_fraction": 0.5782420181}
class Multimap {
    constructor() {
        this._map = new Map();
    }

    set(key, value) {
        var set = this._map.get(key);
        if (!set) {
            set = new Set();
            this._map.set(key, set);
        }
        set.add(value);
    }

    has(key, value) {
        if (!this._map.has(key))
            return false;
        return this._map.get(key).has(value);
    }

    delete(key, value) {
        var set = this._map.get(key);
        if (!set)
            return;
        set.delete(value);
        if (!value.size)
            this._map.delete(key);
    }

    get(key) {
        if (!this._map.has(key))
            return new Set();
        return this._map.get(key);
    }

    get size() {
        var result = 0;
        for (var value of this._map.values())
            result += value.size;
        return result;
    }

    keysArray() {
        return Array.from(this._map.keys());
    }
}

Set.prototype.deleteAll = function(other) {
    for (var e of other)
        this.delete(e);
}

Set.prototype.first = function() {
    return this.values().next().value || null;
}

Promise.prototype.catchError = function(defaultValue) {
    return this.catch(error => {
        console.error(error);
        return defaultValue;
    });
}

/**
 * @param {string} nodeName
 * @param {string} className
 * @return {!Element}
 */
function createElementWithClass(nodeName, className) {
    var elem = document.createElement(nodeName);
    elem.className = className || '';
    return elem;
}

/**
 * @param {string} nodeName
 * @param {string} className
 * @return {!Element}
 */
Element.prototype.createChild = function(nodeName, className) {
    var elem = createElementWithClass(nodeName, className);
    this.appendChild(elem);
    return elem;
}

class EventEmitter {
    constructor() {
        this._eventListeners = new Multimap();
    }

    addListener(eventType, handler) {
        this._eventListeners.set(eventType, handler);
    }

    removeListener(eventType, handler) {
        this._eventListeners.delete(eventType, handler);
    }

    dispatch(eventType, data) {
        var handlers = Array.from(this._eventListeners.get(eventType));
        for (var handler of handlers)
            handler.call(null, data);
    }
}

function getLocalStorage() {
  var testKey = 'test', storage = window.localStorage;
  if (!storage)
    return null;
  try {
    storage.setItem(testKey, '1');
    storage.removeItem(testKey);
    return window.localStorage;
  } catch (error) {
    return null
  }
}
