{"size": 846, "ext": "js", "max_stars_repo_path": "lib/subscriberlist.js", "max_stars_repo_name": "meqif/ridethelightning", "max_stars_repo_stars_event_min_datetime": "2016-05-11T14:35:38.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-19T16:53:36.000Z", "max_issues_repo_path": "lib/subscriberlist.js", "max_issues_repo_name": "meqif/ridethelightning", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/subscriberlist.js", "max_forks_repo_name": "meqif/ridethelightning", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.6923076923, "max_line_length": 62, "alphanum_fraction": 0.5130023641}
var _ = require('underscore');

var subscribers = [];

module.exports = {
    add: function(token, latitude, longitude) {
        this.remove(token);
        subscribers.push({
            token: token,
            latitude: latitude,
            longitude: longitude
        });
    },

    remove: function(token) {
        if (this.contains(token)) {
            subscribers = _.reject(subscribers, function(el) {
                return el.token === token;
            });
            return true;
        } else {
            return false;
        }
    },

    contains: function(token) {
        return !! this.find(token);
    },

    find: function(token) {
        var searchProperty = { token: token };
        return _.findWhere(subscribers, searchProperty);
    },

    all: function() {
        return _.clone(subscribers);
    }
};
