destructured parameter

/**
 * create an array of numbers
 * ### Examples
 * ```
 * array(5) => [0,1,2,3,4]
 * array(5, {start: 1}) => [1,2,3,4,5]
 * array(3, {start: -1, step: -2}) => [-1, -3, -5]
 * ```
 * ### Parameters
 * @param {number} count - number of elements
 * @param {Object} opts - options
 * @param {number} [opts.start=0] - where to start the array (default: 0)
 * @param {number} [opts.step=1] - the difference between two numbers (default: 1)
 */
export function array(count, { start = 0, step = 1 } = {}) {
  return [...List(count, { start, step })];
}

Last updated