<commit_before>/**
 * @file Get attributes from a class definition
 * @since 0.2.4
 */
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*#endif*/

function _gpfDefClassAttrFilter (attributes, baseAttributeClass) {
    if (baseAttributeClass) {
        return attributes.filter(function (attribute) {
            return attribute instanceof baseAttributeClass;
        });
    }
    return attributes;
}

function _gpfDefClassAttrAssign (allAttributes, member, attributes) {
    allAttributes[member] = (allAttributes[member] || []).concat(attributes);
}

Object.assign(_GpfClassDefinition.prototype, {

    _collectAttributes: function (allAttributes, baseAttributeClass) {
        _gpfObjectForEach(this._attributes, function (memberAttributes, member) {
            var attributes = _gpfDefClassAttrFilter(memberAttributes, baseAttributeClass);
            if (attributes.length) {
                _gpfDefClassAttrAssign(allAttributes, member, attributes);
            }
        });
        if (this._extendDefinition) {
            this._extendDefinition._collectAttributes(allAttributes, baseAttributeClass);
        }
    },

    /**
     * Retrieve all attributes for this class definition (including inherited ones)
     *
     * @param {gpf.attributes.Attribute} [baseAttributeClass] Base attribute class used to filter results
     * @return {Object} Dictionary of attributes grouped per members
     * @since 0.2.4
     */
    getAttributes: function (baseAttributeClass) {
        var allAttributes = {};
        this._collectAttributes(allAttributes, baseAttributeClass);
        return allAttributes;
    }

});
<commit_msg>Collect own attributes (#282)<commit_after>/**
 * @file Get attributes from a class definition
 * @since 0.2.4
 */
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*#endif*/

function _gpfDefClassAttrFilter (attributes, baseAttributeClass) {
    if (baseAttributeClass) {
        return attributes.filter(function (attribute) {
            return attribute instanceof baseAttributeClass;
        });
    }
    return attributes;
}

function _gpfDefClassAttrAssign (allAttributes, member, attributes) {
    allAttributes[member] = (allAttributes[member] || []).concat(attributes);
}

Object.assign(_GpfClassDefinition.prototype, {

    _collectOwnAttributes: function (allAttributes, baseAttributeClass) {
        _gpfObjectForEach(this._attributes, function (memberAttributes, member) {
            var attributes = _gpfDefClassAttrFilter(memberAttributes, baseAttributeClass);
            if (attributes.length) {
                _gpfDefClassAttrAssign(allAttributes, member, attributes);
            }
        });
    },

    _getOwnAttributes: function () {
        var ownAttributes = {};
        this._collectOwnAttributes(ownAttributes);
        return ownAttributes;
    },

    _collectAttributes: function (allAttributes, baseAttributeClass) {
        this._collectOwnAttributes(allAttributes, baseAttributeClass);
        if (this._extendDefinition) {
            this._extendDefinition._collectAttributes(allAttributes, baseAttributeClass);
        }
    },

    /**
     * Retrieve all attributes for this class definition (including inherited ones)
     *
     * @param {gpf.attributes.Attribute} [baseAttributeClass] Base attribute class used to filter results
     * @return {Object} Dictionary of attributes grouped per members
     * @since 0.2.4
     */
    getAttributes: function (baseAttributeClass) {
        var allAttributes = {};
        this._collectAttributes(allAttributes, baseAttributeClass);
        return allAttributes;
    }

});

{'fraction_non_alphanumeric': 0.09976371751115778, 'fraction_numerical': 0.0039380414807035965, 'mean_word_length': 3.3197278911564627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4615500', 'n_tokens_mistral': 973, 'n_tokens_neox': 954, 'n_words': 236}