<commit_before>import { define } from '../helpers/obj-define.js';
import { reduceObjectProperty } from '../lib/reduce.js';
import { isFalsy, isUndefined } from '../lib/typeof.js';
import { dispatch } from '../lib/dispatch.js';
import { prop, Property } from '../lib/property.js';

/**
 * Try to parse attribute value checking the property validation types.
 * @private
 *
 * @param {Property} property The property to update.
 * @param {String} attrVal The attribute value.
 * @return {*} The parsed value.
 */
function getValue(property, attrVal) {
    if (attrVal === '' && property.accepts(Boolean)) {
        return true;
    }
    if (!property.accepts(String)) {
        try {
            return JSON.parse(attrVal);
        } catch (ex) {
            //
        }
    }
    return attrVal;
}

/**
 * Set an attribute value checking its type.<commit_msg>feat: consider valid boolean property when string value equals property name<commit_after>import { define } from '../helpers/obj-define.js';
import { reduceObjectProperty } from '../lib/reduce.js';
import { isFalsy, isUndefined } from '../lib/typeof.js';
import { dispatch } from '../lib/dispatch.js';
import { prop, Property } from '../lib/property.js';

/**
 * Try to parse attribute value checking the property validation types.
 * @private
 *
 * @param {Property} property The property to update.
 * @param {String} attrVal The attribute value.
 * @return {*} The parsed value.
 */
function getValue(property, attrVal) {
    if ((attrVal === '' || property.name === attrVal) && property.accepts(Boolean)) {
        return true;
    }
    if (!property.accepts(String)) {
        try {
            return JSON.parse(attrVal);
        } catch (ex) {
            //
        }
    }
    return attrVal;
}

/**
 * Set an attribute value checking its type.
{'fraction_non_alphanumeric': 0.14608599779492834, 'fraction_numerical': 0.0, 'mean_word_length': 2.7655601659751037, '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': '4111876', 'n_tokens_mistral': 509, 'n_tokens_neox': 510, 'n_words': 159}