<commit_before>/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
const Promise = require("../../../global/Promise");
const DiscoveryQos = require("../../../generated/joynr/types/DiscoveryQos");
const UtilInternal = require("../../util/UtilInternal");
const DiscoveryException = require("../../exceptions/DiscoveryException");
const NoCompatibleProviderFoundException = require("../../exceptions/NoCompatibleProviderFoundException");
const LongTimer = require("../../util/LongTimer");

/**
 * checks if the provided discoveryEntry supports onChange subscriptions if required
 *
 * @name Arbitrator#checkSupportsOnChangeSubscriptions
 * @function
 *
 * @param {DiscoveryEntry} discoveryEntry - the discovery entry to check
 * @param {Boolean} providerMustSupportOnChange - filter only entries supporting onChange subscriptions
 */
function checkSupportsOnChangeSubscriptions(discoveryEntry, providerMustSupportOnChange) {
    if (providerMustSupportOnChange === undefined || !providerMustSupportOnChange) {
        return true;
    }
    if (discoveryEntry.qos === undefined) {
        return false;
    }
    return discoveryEntry.qos.supportsOnChangeSubscriptions;
}

function discoverStaticCapabilities(capabilities, domains, interfaceName, discoveryQos, proxyVersion, deferred) {
    try {
        const arbitratedCaps = [];

        deferred.pending = false;
        if (capabilities === undefined) {
            deferred.reject(new Error("Exception while arbitrating: static capabilities are missing"));
        } else {
            for (let i = 0; i < capabilities.length; ++i) {
                const capability = capabilities[i];
                if (
                    domains.indexOf(capability.domain) !== -1 &&
                    interfaceName === capability.interfaceName &&
                    capability.providerVersion.MAJOR_VERSION === proxyVersion.MAJOR_VERSION &&
                    capability.providerVersion.MINOR_VERSION === proxyVersion.MINOR_VERSION &&<commit_msg>[JS] fix version check in Arbitrator.discoverStaticCapabilities<commit_after>/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
const Promise = require("../../../global/Promise");
const DiscoveryQos = require("../../../generated/joynr/types/DiscoveryQos");
const UtilInternal = require("../../util/UtilInternal");
const DiscoveryException = require("../../exceptions/DiscoveryException");
const NoCompatibleProviderFoundException = require("../../exceptions/NoCompatibleProviderFoundException");
const LongTimer = require("../../util/LongTimer");

/**
 * checks if the provided discoveryEntry supports onChange subscriptions if required
 *
 * @name Arbitrator#checkSupportsOnChangeSubscriptions
 * @function
 *
 * @param {DiscoveryEntry} discoveryEntry - the discovery entry to check
 * @param {Boolean} providerMustSupportOnChange - filter only entries supporting onChange subscriptions
 */
function checkSupportsOnChangeSubscriptions(discoveryEntry, providerMustSupportOnChange) {
    if (providerMustSupportOnChange === undefined || !providerMustSupportOnChange) {
        return true;
    }
    if (discoveryEntry.qos === undefined) {
        return false;
    }
    return discoveryEntry.qos.supportsOnChangeSubscriptions;
}

function discoverStaticCapabilities(capabilities, domains, interfaceName, discoveryQos, proxyVersion, deferred) {
    try {
        const arbitratedCaps = [];

        deferred.pending = false;
        if (capabilities === undefined) {
            deferred.reject(new Error("Exception while arbitrating: static capabilities are missing"));
        } else {
            for (let i = 0; i < capabilities.length; ++i) {
                const capability = capabilities[i];
                if (
                    domains.indexOf(capability.domain) !== -1 &&
                    interfaceName === capability.interfaceName &&
                    capability.providerVersion.majorVersion === proxyVersion.majorVersion &&
                    capability.providerVersion.minorVersion >= proxyVersion.minorVersion &&
{'fraction_non_alphanumeric': 0.1062151241100635, 'fraction_numerical': 0.005387723686742351, 'mean_word_length': 3.371740958788898, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1092220', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1237, 'n_words': 397}