<commit_before>// grunt-merge-data
// Copyright (c) 2013 <NAME>
// Licensed under the MIT license.

module.exports = function (grunt) {
  'use strict';
  
  var path = require('path');
  
  function mergeObjects (destObj, srcObj) {
    for (var attrname in srcObj) {
      if (srcObj.hasOwnProperty(attrname)) {
        destObj[attrname] = srcObj[attrname];
      }
    }
  }
  
  function mergeFileData (sources) {
    var data = {};
    sources.filter(function (filePath) {
      // Warn on and remove invalid source files (if nonull was set)
      if (!grunt.file.exists(filePath)) {
        grunt.log.warn('Source file "' + filePath + '" not found.');
        return false;
      } else {
        return true;
      }

    }).forEach(function (filePath) {
      var basename = path.basename(filePath, path.extname(filePath));
      var ext = path.extname(filePath).toLowerCase();
      
      if(ext === '.json') {
        data[basename] = grunt.file.readJSON(filePath);
      } else if (ext === '.yml' || ext === '.yaml') {
        data[basename] = grunt.file.readYAML(filePath);
      }
    });
    
    return data;
  }
  
  var mergeDataTask = function () {
    // Merge task-specific and/or target-specific options with these defaults
    var options = this.options({
      data: null,
      space: null,
      asConfig: false
    });
    
    // Iterate over all specified src/dest file groups
    this.files.forEach(function (file) {

      var data = mergeFileData(file.src);
      
      if (options.data) {
        if (typeof options.data === 'function') {
          mergeObjects(data, options.data(data));
        } else {
          mergeObjects(data, options.data);
        }
      }
      
      if (typeof options.asConfig === 'string') {
        grunt.config(options.asConfig, data);
        
      } else if (options.asConfig === true) {
        var nameArgs = grunt.task.current.nameArgs;<commit_msg>use grunt.util.kindOf for type check<commit_after>// grunt-merge-data
// Copyright (c) 2013 <NAME>
// Licensed under the MIT license.

module.exports = function (grunt) {
  'use strict';
  
  var path = require('path');
  
  function mergeObjects (destObj, srcObj) {
    for (var attrname in srcObj) {
      if (srcObj.hasOwnProperty(attrname)) {
        destObj[attrname] = srcObj[attrname];
      }
    }
  }
  
  function mergeFileData (sources) {
    var data = {};
    sources.filter(function (filePath) {
      // Warn on and remove invalid source files (if nonull was set)
      if (!grunt.file.exists(filePath)) {
        grunt.log.warn('Source file "' + filePath + '" not found.');
        return false;
      } else {
        return true;
      }

    }).forEach(function (filePath) {
      var basename = path.basename(filePath, path.extname(filePath));
      var ext = path.extname(filePath).toLowerCase();
      
      if(ext === '.json') {
        data[basename] = grunt.file.readJSON(filePath);
      } else if (ext === '.yml' || ext === '.yaml') {
        data[basename] = grunt.file.readYAML(filePath);
      }
    });
    
    return data;
  }
  
  var mergeDataTask = function () {
    // Merge task-specific and/or target-specific options with these defaults
    var options = this.options({
      data: null,
      space: null,
      asConfig: false
    });
    
    // Iterate over all specified src/dest file groups
    this.files.forEach(function (file) {

      var data = mergeFileData(file.src);
      
      if (options.data) {
        if (grunt.util.kindOf(options.data) === 'function') {
          mergeObjects(data, options.data(data));
        } else {
          mergeObjects(data, options.data);
        }
      }
      
      if (grunt.util.kindOf(options.asConfig) === 'string') {
        grunt.config(options.asConfig, data);
        
      } else if (options.asConfig === true) {
        var nameArgs = grunt.task.current.nameArgs;
{'fraction_non_alphanumeric': 0.13628182051941373, 'fraction_numerical': 0.0020570840833119054, 'mean_word_length': 2.2443703085904922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '615964', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1199, 'n_words': 283}