From e1336581dc040f345f6d28524cb85e878c821782 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 16 May 2017 10:44:48 +0200 Subject: [PATCH] simplify getOutline function --- src/Slice.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Slice.js b/src/Slice.js index c5ef883..c9a1ea3 100644 --- a/src/Slice.js +++ b/src/Slice.js @@ -5,17 +5,10 @@ export default class { this.parts = []; } getOutline() { - const outLines = new Shape([], true); - - for (let i = 0; i < this.parts.length; i ++) { - const part = this.parts[i]; - - if (part.shape.closed) { - outLines.join(this.parts[i].outerLine); - } - } - - return outLines; + return this.parts.reduce((shape, part) => { + if (part.outerLine) shape.join(part.outerLine); + return shape; + }, new Shape([], true)); } add(shape) { const part = { shape };