Skip to content

Commit

Permalink
refactor: plot.add simplified with array.flat (closes #68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebeamish committed Sep 14, 2024
1 parent 483fe0f commit 0596735
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions source/Plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,8 @@ plot.generate = () => {
plot.draw();
*/
add(shape) {
if (Array.isArray(shape)) {
shape.forEach((item) => {
if (Array.isArray(item)) {
this.add(item);
} else {
this.addSingleShape(item);
}
});
} else {
this.addSingleShape(shape);
}
const shapes = Array.isArray(shape) ? shape.flat(Infinity) : [shape];
shapes.forEach((item) => this.addSingleShape(item));
}

/**
Expand Down

0 comments on commit 0596735

Please sign in to comment.