All files array.js

100% Statements 10/10
92.31% Branches 12/13
100% Functions 1/1
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  10x 10x 10x     10x 3x     10x 10x 29x     10x    
export function range(start, stop, step = 1) {
  start = isNaN(+start) ? 0 : +start;
  stop = isNaN(+stop) ? 0 : +stop;
  step = isNaN(+step) ? 1 : +step;
 
  // 保证step正确
  if (start > stop && step > 0) {
    step = -step;
  }
 
  const arr = [];
  for (let i = start; start > stop ? i > stop : i < stop; i += step) {
    arr.push(i);
  }
 
  return arr;
}