"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
exports.split = split;
/** @module */
/**
 * Split array into multiple arrays by specified condition.
 *
 * @param {Array} arr Target array.
 * @param {splitCallback} func Callback to split array.
 * @param {boolean} [keepSplitValue=false] Keep split value. The split
 *     point is before the matched value.
 * @returns {Array[]} Split array.
 */
function split(arr, func, keepSplitValue = false) {
  const ret = [[]];
  for (const value of arr) {
    /**
     * Return true at the split point.
     *
     * @callback splitCallback
     * @param {*} value
     */
    if (func(value)) {
      ret.push(keepSplitValue ? [value] : []);
    } else {
      ret[ret.length - 1].push(value);
    }
  }
  return ret;
}
var _default = exports.default = split;