caution: as a side-effect, this may sort the files Array
@param {String} dir
@param {String[]} files
@ignore
function detectDirType(dir, files) {
  var type, isIndexedFiles, isLengthMatched;
  type = 'object';
  isIndexedFiles = false;
  isLengthMatched = false;
  if (path.extname(dir) === '.array') {
    if (!files.length) {
      return 'array';
    }
    // double-check to see if its contents are Array-compatible
    isIndexedFiles = files.every(function (file) {
      var parts, index;
      parts = parseName(file);
      if (!parts.label || !(/^\d+$/).test(parts.label)) {
        return false;
      }
      index = parseInt(parts.label, 10);
      return index < files.length;
    });
    if (!isIndexedFiles) {
      return 'object';
    }
    files.sort(function (a, b) {
      return parseInt(a, 10) - parseInt(b, 10);
    });
    isLengthMatched =
      parseInt(files[files.length - 1], 10) === files.length - 1;
    if (isLengthMatched) {
      return 'array';
    }
  }
  return type;
}