import quickSort from './quickSort';
import mergeSort from './mergeSort';
export function forEach(array, func) {
  let i = -1;
  while(++i < array.length)
    func(array[i], i, array);
  return array;
}
export function reduce(array, func, base) {
  let i = -1;
  while(++i < array.length)
    base = func(base, array[i], i, array);
  return base;
}
export function reduceRight(array, func, base) {
  let i = array.length;
  while(--i >= 0)
    base = func(base, array[i], i, array);
  return base;
}
export const map = (array, func) => reduce(array, (result, value, index, array) => add(result, func(value, index, array)), []);
export const mapToObject = (array, func) => reduce(array, (obj, value, index, array) => {
  obj[func(value, index, array)] = value;
  return obj;
}, Object.create(null));
export const mapToMap = (array, func) => new Map(map(array, func));
export const filter = (array, func = (x) => !!x) => reduce(array, (result, value, index, array) => func(value, index, array)
  ? add(result, value)
  : result, []);
export function find(array, func) {
  let i = -1;
  while(++i < array.length) {
    if(func(array[i], i, array))
      return array[i];
  }
  
  return null;
}
export function times(length, func) {
  const result = [];
  let i = -1;
  while(++i < length) {
    result.push(func(i, length));
  }
  return result;
}
export const difference = (array, targetArray) => filter(array, (val) => targetArray.indexOf(val) === -1);
export const intersection = (array, targetArray) => filter(array, (val) => targetArray.indexOf(val) !== -1);
export const flatten = (array) => [].concat.apply([], array);
export const unique = (array) => filter(array, (value, index, self) => self.indexOf(value) === index);
export function uniqueBy(array, func) {
  const result = [];
  const resultKeys = [];
  let i = -1;
  while(++i < array.length) {
    const key = func(array[i], i, array);
    if(!find(resultKeys, (resultKey) => key === resultKey)) {
      result.push(array[i]);
      resultKeys.push(key);
    }
  }
  return result;
}
export const countBy = (array, func) => {
  const result = Object.create(null);
  const len = array.length;
  let i = -1;
  while(++i < len) {
    const key = func(array[i], i, array);
    if(!result[key])
      result[key] = 0;
    ++result[key];
  }
  return result;
};
export const has = (array, value) => array.indexOf(value) !== -1;
export const invoke = (array) => forEach(array, (func) => func());
export const concat = (...arrays) => flatten(arrays);
export const union = (...arrays) => unique(concat(...arrays));
export const qkSort = (array, func, ascending = true) => !ascending
  ? reverse(quickSort([...array], func))
  : quickSort([...array], func);
export const mgSort = (array, func, ascending = true) => !ascending
  ? reverse(mergeSort([...array], func))
  : mergeSort([...array], func);
export function reverse(array) {
  const result = [];
  for(let i = array.length - 1; i >= 0; i--) {
    result.push(array[i]);
  }
  return result;
}
export const qkHeuristicFind = (array, func) => qkSort(array, func, false)[0];
export const mgHeuristicFind = (array, func) => mgSort(array, func, false)[0];
export const heuristicFind = mgHeuristicFind;
export const contains = (array, value) => array.indexOf(value) !== -1;
export const copy = (array) => array.slice(0);
export const toggle = (array, value) => contains(array, value)
  ? remove(array, value)
  : add(array, value);
export const remove = (array, value) => {
  const result = copy(array);
  if(array.indexOf(value) !== -1) {
    result.splice(array.indexOf(value), 1);
  }
  return result;
};
export const add = (array, value, index = 0) => {
  const result = copy(array);
  result.splice(index, 0, value);
  return result;
};
export const insert = (array, index, ...values) => copy(array).splice(index, 0, ...values);
export const chunk = (array, chunkSize = 10) => times(Math.ceil(array.length / chunkSize), (index) => array.slice(index * chunkSize, index * chunkSize + chunkSize));
export const last = (array, pos = 0) => array[array.length - 1 - pos];
export function lastValues(array, num = 1) {
  const result = [];
  let i = array.length;
  const min = Math.max(array.length - 1 - num, 0);
  while(--i > min)
    result.push(array[i]);
  return result;
}
export const first = (array, pos = 0) => array[0 + pos];
export function firstValues(array, num = 1) {
  const result = [];
  let i = 0;
  while(i < num && i < array.length)
    result.push(array[i++]);
  return result;
}
export const any = (array, func) => !!find(array, func);
export const all = (array, func) => !find(array, (value, i, array) => !func(value, i, array));
export function chain(initValue = []) {
  let value = initValue;
  const chain = {
    link: (func, ...args) => {
      value = func(value, ...args);
      return chain;
    },
    value: () => value,
  };
  return chain;
}
//# sourceMappingURL=index.js.map
@@ -1602,19 +1602,12 @@
 ncat
-.apply(%5B%5D, 
+(...
 arra

remove .apply()