'use strict';

var utils = {};

// detect object type
utils.type = function(obj) {
  return Object.prototype.toString.call(obj).split(' ')[1].replace(']', '');
};

utils.each = function(stack, handler) {
  var len = stack.length;

  // Array
  if (len) {
    for (var i = 0; i < len; i++) {
      if (handler.call(stack[i], stack[i], i) === false) {
        break;
      }
    }
  }
  // Object
  else if (typeof len === 'undefined') {
    for (var name in stack) {
      if (handler.call(stack[name], stack[name], name) === false) {
        break;
      }
    }
  }
};

// shallow copy
// utils.extend(target, obj1, obj2, ...)
utils.extend = function(target) {
  utils.each(arguments, function(source, index) {
    if (index > 0) {
      utils.each(source, function(value, key) {
        if (typeof value !== 'undefined') {
          target[key] = value;
        }
      });
    }
  });
};

// setter
utils.setter = function(target, name, value) {
  var nameType = utils.type(name);

  // setter(name, value)
  if (nameType === 'String') {
    if (typeof target[name] === 'undefined') {
      throw new Error('Invalid configuration name.');
    }

    if (typeof value === 'undefined') {
      throw new Error('Lack of a value corresponding to the name');
    }

    if (utils.type(value) === 'Object' && utils.type(target[name]) === 'Object') {
      utils.extend(target[name], value);
    } else {
      target[name] = value;
    }
  }
  // setter({...})
  else if (nameType === 'Object') {
    value = name;
    utils.extend(target, value);
  }
  // otherwise throws
  else {
    throw new Error('Invalid arguments');
  }
};

// sort and unique for array
utils.sortAndUnique = function(arr) {
  var result = [];
  var lineHash = {};

  utils.each(arr, function(line) {
    if (!lineHash[line]) {
      result.push(line);
      lineHash[line] = true;
    }
  });

  return result.sort(function(a, b) {
    return a - b > 0;
  });
};

// get file format
utils.getFileFormat = function(str) {
  var format = str.substr(str.lastIndexOf('.') + 1, str.length);
  return format;
};

module.exports = utils;

@@ -889,746 +889,8 @@
 %7D;%0A%0A
-// setter%0Autils.setter = function(target, name, value) %7B%0A  var nameType = utils.type(name);%0A%0A  // setter(name, value)%0A  if (nameType === 'String') %7B%0A    if (typeof target%5Bname%5D === 'undefined') %7B%0A      throw new Error('Invalid configuration name.');%0A    %7D%0A%0A    if (typeof value === 'undefined') %7B%0A      throw new Error('Lack of a value corresponding to the name');%0A    %7D%0A%0A    if (utils.type(value) === 'Object' && utils.type(target%5Bname%5D) === 'Object') %7B%0A      utils.extend(target%5Bname%5D, value);%0A    %7D else %7B%0A      target%5Bname%5D = value;%0A    %7D%0A  %7D%0A  // setter(%7B...%7D)%0A  else if (nameType === 'Object') %7B%0A    value = name;%0A    utils.extend(target, value);%0A  %7D%0A  // otherwise throws%0A  else %7B%0A    throw new Error('Invalid arguments');%0A  %7D%0A%7D;%0A%0A
 // s
@@ -1196,151 +1196,8 @@
 %7D;%0A%0A
-// get file format%0Autils.getFileFormat = function(str) %7B%0A  var format = str.substr(str.lastIndexOf('.') + 1, str.length);%0A  return format;%0A%7D;%0A%0A
 modu

remove abandoned part