From 7758ba81a6a1356e71e4af9298392b6ac4e1d833 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Mon, 23 Jul 2018 17:35:06 +0000 Subject: [PATCH] :construction: Moved return statement to bottom to avoid warnings --- rollup.browser.js | 6 +++--- src/attributes.js | 4 ++-- src/part.js | 7 +++---- src/path.js | 2 ++ src/pattern.js | 4 ++-- src/point.js | 4 ++-- src/svg.js | 11 +++++++++-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/rollup.browser.js b/rollup.browser.js index 606cb3abe7f..676dfd30d99 100644 --- a/rollup.browser.js +++ b/rollup.browser.js @@ -10,7 +10,8 @@ export default { file: "dist/freesewing.min.js", format: "iife", name: "freesewing", - banner: `/**\n * Freesewing\n * (c) ${new Date().getFullYear()} Joost De Cock\n * @license MIT\n */` + banner: `/**\n * Freesewing\n * (c) ${new Date().getFullYear()} Joost De Cock\n * @license MIT\n */`, + sourcemap: true }, plugins: [ resolve({ @@ -20,7 +21,6 @@ export default { commonjs(), babel({ exclude: "node_modules/**" - }), - terser() + }) ] }; diff --git a/src/attributes.js b/src/attributes.js index fdaf369bdb2..0587b0c0f5b 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -6,8 +6,6 @@ function attributes(init = false) { } } - return this; - /** Adds an attribute */ this.prototype.add = function(name, value) { if (typeof this.list[name] === "undefined") { @@ -47,6 +45,8 @@ function attributes(init = false) { return svg; }; + + return this; } export default attributes; diff --git a/src/part.js b/src/part.js index cb0f1aefb0e..7c9ef987d7d 100644 --- a/src/part.js +++ b/src/part.js @@ -3,8 +3,7 @@ import point from "./point"; import * as hooklib from "hooks"; function part(id) { - attributes = new Attributes(); - + this.attributes = new Attributes(); this.points = {}; this.paths = {}; this.snippets = {}; @@ -13,8 +12,6 @@ function part(id) { this.points.origin = new point(0, 0); for (let k in hooklib) this[k] = hooklib[k]; - return this; - this.prototype.macroRunner = function(args) { let self = this; let data = args; @@ -27,6 +24,8 @@ function part(id) { return method; }; + + return this; } export default part; diff --git a/src/path.js b/src/path.js index 399fd258684..bdd3f5e3ef3 100644 --- a/src/path.js +++ b/src/path.js @@ -66,6 +66,8 @@ function path() { return d; }; + + return this; } export default path; diff --git a/src/pattern.js b/src/pattern.js index ac9e48c7ec6..0efecebc6e9 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -53,8 +53,6 @@ export default function pattern(config = false) { config: this.config }; - return this; - /** * @throws Will throw an error when called */ @@ -112,4 +110,6 @@ export default function pattern(config = false) { } } }; + + return this; } diff --git a/src/point.js b/src/point.js index 6aca2b57feb..cf8deaf5a25 100644 --- a/src/point.js +++ b/src/point.js @@ -5,8 +5,6 @@ function point(x, y) { this.y = this.round(y); this.attributes = new attributes(); - return this; - /** Rounds a value to PRECISION */ this.prototype.round = function(value) { return Math.round(value * 1e2) / 1e2; @@ -113,6 +111,8 @@ function point(x, y) { this.prototype.shiftOutwards = function(that, distance) { return this.shiftTowards(that, this.dist(that) + distance); }; + + return this; } export default point; diff --git a/src/svg.js b/src/svg.js index 4f175e7ae26..de049807943 100644 --- a/src/svg.js +++ b/src/svg.js @@ -2,6 +2,8 @@ import attributes from "./attributes"; import * as hooklib from "hooks"; import hooks from "./hooks"; +import { version } from "../package.json"; + function svg(pattern) { this.body = ""; this.style = ""; @@ -15,12 +17,15 @@ function svg(pattern) { this.attributes.add("xmlns", "http://www.w3.org/2000/svg"); this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg"); this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink"); + this.attributes.add( + "xmlns:freesewing", + "http://freesewing.org/namespaces/freesewing" + ); + this.attributes.add("freesewing", version); this.hooks = hooks.all; for (let k in hooklib) this[k] = hooklib[k]; for (let k in this.hooks) this.hook(k, this[k]); - return this; - /** Method to attach preRenderSvg hooks on */ this.prototype.preRenderSvg = function() {}; @@ -240,6 +245,8 @@ function svg(pattern) { return "" + this.freeId; }; + + return this; } export default svg;