"use strict";
/**
 * Matcher for browser
 * @module
 */
var compareVersion = require('../compare_version').compareVersion;
/**
 * @type ConditionMatcher
 */
module.exports = {
    // specify the fields needed
    fieldsNeeded: ['browserVersion', 'browserId'],
    /**
     * @param {Object} value
     * @param {Condition} cond
     * @return {Boolean}
     */
    match: function (value, cond) {
        var targetedBrowser = cond.value, browserName = value.browserId, browserVersion = value.browserVersion;
        if (targetedBrowser.indexOf(browserName) === 0) {
            var targetedVersion = targetedBrowser.substr(browserName.length);
            return compareVersion(browserVersion, targetedVersion) === 0;
        }
        return false;
    },
};
