array/take.jsjavascript
/**
 * 从数组左侧获取指定数量的元素。
 * @function take
 * @memberof module:array
 * @param {Array} array 原数组
 * @param {number} [count=1] 获取数量
 * @returns {Array} 新数组
 * @throws {TypeError} 参数类型不正确时抛出
 */
function take(array, count = 1) {
  if (!Array.isArray(array)) throw new TypeError('array must be an array')
  if (!Number.isInteger(count)) throw new TypeError('count must be an integer')
  return array.slice(0, Math.max(0, count))
}

export default take