<commit_before>// Copyright (c) CBC/Radio-Canada. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

define(['lodash'],
    function(_) {
        'use strict';

        var ObjectUtilities = function(){};

        ObjectUtilities.prototype.pickNonFalsy = function(source) {
            //var self = this;

            return  _.pickBy(source, function(x){ return x && !_.isEmpty(x); });
        };

        ObjectUtilities.prototype.pickInBoth = function(source, otherSource) {
            //var self = this;

            return _.pickBy(source, function(value, key /*, object*/ ) {
                return _.has(otherSource, key);
            });
        };

        ObjectUtilities.prototype.traverse = function(o, func) {
            var self = this;

            for (var i in o) {
                func.apply(this, [i, o[i]]);
                if (o[i] !== null && typeof(o[i]) === 'object') {
                    //going on step down in the object tree!!
                    self.traverse(o[i], func);
                }
            }
        };

        return new ObjectUtilities();<commit_msg>Fixed pickNonFalsy: numbers were not picked<commit_after>// Copyright (c) CBC/Radio-Canada. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

define(['lodash'],
    function(_) {
        'use strict';

        var ObjectUtilities = function(){};

        ObjectUtilities.prototype.pickNonFalsy = function(source) {
            return  _.pickBy(source, function(value) { return !isFalsyOrEmpty(value); });
        };

        function isFalsyOrEmpty(value) {
            if (!value) {
                return true;
            }

            if (_.isObject(value) && _.isEmpty(value)) {
                return true;
            }

            return false;
        }

        ObjectUtilities.prototype.pickInBoth = function(source, otherSource) {
            return _.pickBy(source, function(value, key /*, object*/ ) {
                return _.has(otherSource, key);
            });
        };

        ObjectUtilities.prototype.traverse = function(o, func) {
            for (var i in o) {
                func.apply(this, [i, o[i]]);
                if (o[i] !== null && typeof(o[i]) === 'object') {
                    //going on step down in the object tree!!
                    this.traverse(o[i], func);
                }
            }
        };

        return new ObjectUtilities();
{'fraction_non_alphanumeric': 0.1253943217665615, 'fraction_numerical': 0.0, 'mean_word_length': 1.6932059447983014, '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': '2230677', 'n_tokens_mistral': 692, 'n_tokens_neox': 663, 'n_words': 181}