<commit_before>// Gets number of items if the value is a Collection, Array or an Array-like, otherwise returns -1.
export default function count(value) {
    return value;
}<commit_msg>implement count function<commit_after>import Iterable from '../iteration/iterable';
import Collection from '../collections/collection';
import isArrayLike from './is-array-like';

// Gets number of items if the value is a Collection, Array or an Array-like, otherwise returns -1.
export default function count(value) {
    if (isArrayLike(value)) {
        return value.length;
    }

    else if (value instanceof Collection) {
        return value.count();
    }

    else if (value instanceof Iterable) {
        if (isArrayLike(value.valueOf())) {
            return value.valueOf().length;
        }
    }

    return -1;
}
{'fraction_non_alphanumeric': 0.1057810578105781, 'fraction_numerical': 0.0036900369003690036, 'mean_word_length': 3.0497512437810945, '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': '734077', 'n_tokens_mistral': 217, 'n_tokens_neox': 215, 'n_words': 81}