/**
 * This function does nothing.
 *
 * @return {void} No return value.
 */
export const noop = () => {
  /** */
}
/**
 * @description Add the number of cuts based on the original split and return all subsets after the cut
 * @param str need to split of primitive string
 * @param splitStr split params
 * @param num split limit
 * @returns a new split array, length is num + 1
 */
export function mulSplit(str: string, splitStr: string, num = -1) {
  const splitList = str.split(splitStr, num)
  if (num === -1) return splitList
  const originStr = splitList.join(splitStr)
  if (originStr === str) return splitList
  const endStr = str.slice(originStr.length + 1)
  splitList.push(endStr)
  return splitList
}

/**
 * Sleeps for a given delay.
 *
 * @param {number} delay - The delay, in milliseconds.
 * @return {Promise<void>} A promise that resolves after the delay.
 */
export const sleep = (delay: number) =>
  new Promise((resolve) => setTimeout(resolve, delay))
