Cleaning up some of the arrow function syntax
Don't need to use `return` as much as I had been
This commit is contained in:
parent
2ceb94fc42
commit
1b22d0b717
@ -1,8 +1,6 @@
|
||||
export default {
|
||||
_render() {
|
||||
return this.renderLabel(this.label).then(label => {
|
||||
return label.addClass('anchor');
|
||||
});
|
||||
return this.renderLabel(this.label).then(label => label.addClass('anchor'));
|
||||
},
|
||||
|
||||
setup() {
|
||||
|
@ -28,9 +28,9 @@ export default {
|
||||
this.partContainer = this.container.group();
|
||||
|
||||
// Renders each part of the charset into the part container.
|
||||
return Promise.all(_.map(this.elements, part => {
|
||||
return part.render(this.partContainer.group());
|
||||
}))
|
||||
return Promise.all(_.map(this.elements,
|
||||
part => part.render(this.partContainer.group())
|
||||
))
|
||||
.then(() => {
|
||||
// Space the parts of the charset vertically in the part container.
|
||||
util.spaceVertically(this.elements, {
|
||||
@ -54,9 +54,8 @@ export default {
|
||||
// and text value of the part, so `[aa]` will have only one item, but
|
||||
// `[a\x61]` will contain two since the first matches "a" and the second
|
||||
// matches 0x61 (even though both are an "a").
|
||||
this.elements = _.uniqBy(this.properties.parts.elements, part => {
|
||||
return `${part.type}:${part.textValue}`;
|
||||
});
|
||||
this.elements = _.uniqBy(this.properties.parts.elements,
|
||||
part => `${part.type}:${part.textValue}`);
|
||||
|
||||
// Include a warning for charsets that attempt to match `\c` followed by
|
||||
// any character other than A-Z (case insensitive). Charsets like `[\c@]`
|
||||
|
@ -33,9 +33,7 @@ export default {
|
||||
items;
|
||||
|
||||
// Render each of the match fragments.
|
||||
partPromises = _.map(this.parts, part => {
|
||||
return part.render(this.container.group());
|
||||
});
|
||||
partPromises = _.map(this.parts, part => part.render(this.container.group()));
|
||||
|
||||
items = _(partPromises).compact().value();
|
||||
|
||||
|
@ -15,9 +15,9 @@ export default {
|
||||
.translate(20, 0));
|
||||
|
||||
// Renders each match into the match container.
|
||||
return Promise.all(_.map(this.matches, match => {
|
||||
return match.render(matchContainer.group());
|
||||
}))
|
||||
return Promise.all(_.map(this.matches,
|
||||
match => match.render(matchContainer.group())
|
||||
))
|
||||
.then(() => {
|
||||
let containerBox,
|
||||
paths;
|
||||
@ -30,9 +30,7 @@ export default {
|
||||
containerBox = this.getBBox();
|
||||
|
||||
// Creates the curves from the side lines for each match.
|
||||
paths = _.map(this.matches, match => {
|
||||
return this.makeCurve(containerBox, match)
|
||||
});
|
||||
paths = _.map(this.matches, match => this.makeCurve(containerBox, match));
|
||||
|
||||
// Add side lines to the list of paths.
|
||||
paths.push(this.makeSide(containerBox, _.first(this.matches)));
|
||||
@ -46,9 +44,7 @@ export default {
|
||||
|
||||
// Create connections from side lines to each match and render into
|
||||
// the match container.
|
||||
paths = _.map(this.matches, match => {
|
||||
return this.makeConnector(containerBox, match);
|
||||
});
|
||||
paths = _.map(this.matches, match => this.makeConnector(containerBox, match));
|
||||
matchContainer.prepend(
|
||||
matchContainer.path(paths.join('')));
|
||||
});
|
||||
@ -124,10 +120,10 @@ export default {
|
||||
this.proxy = this.properties.match;
|
||||
} else {
|
||||
// Merge all the match nodes into one array.
|
||||
this.matches = [this.properties.match]
|
||||
.concat(_.map(this.properties.alternates.elements, element => {
|
||||
return element.properties.match;
|
||||
}));
|
||||
this.matches = [this.properties.match].concat(
|
||||
_.map(this.properties.alternates.elements,
|
||||
element => element.properties.match)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -47,9 +47,9 @@ export default {
|
||||
|
||||
setup() {
|
||||
// Convert list of flags into text describing each flag.
|
||||
this.flags = _(this.properties.flags.textValue).uniq().sort().map(flag => {
|
||||
return this.flagLabels[flag];
|
||||
}).value();
|
||||
this.flags = _(this.properties.flags.textValue)
|
||||
.uniq().sort()
|
||||
.map(flag => this.flagLabels[flag]).value();
|
||||
|
||||
this.regexp = this.properties.regexp
|
||||
}
|
||||
|
@ -38,12 +38,10 @@ export default {
|
||||
|
||||
// Render the contained regexp.
|
||||
return this.regexp.render(this.container.group())
|
||||
.then(() => {
|
||||
// Create the labeled box around the regexp.
|
||||
return this.renderLabeledBox(label, this.regexp, {
|
||||
padding: 10
|
||||
});
|
||||
});
|
||||
// Create the labeled box around the regexp.
|
||||
.then(() => this.renderLabeledBox(label, this.regexp, {
|
||||
padding: 10
|
||||
}));
|
||||
},
|
||||
|
||||
// Returns the label for the subexpression.
|
||||
|
@ -183,9 +183,9 @@ export default class Regexper {
|
||||
//
|
||||
// - __warnings__ - Array of warning messages to display.
|
||||
displayWarnings(warnings) {
|
||||
this.warnings.innerHTML = _.map(warnings, warning => {
|
||||
return `<li class="inline-icon">${util.icon("#warning")}${warning}</li>`;
|
||||
}).join('');
|
||||
this.warnings.innerHTML = _.map(warnings, warning => (
|
||||
`<li class="inline-icon">${util.icon("#warning")}${warning}</li>`
|
||||
)).join('');
|
||||
}
|
||||
|
||||
// Render regular expression
|
||||
@ -200,9 +200,7 @@ export default class Regexper {
|
||||
if (this.running) {
|
||||
this.running.cancel();
|
||||
|
||||
return util.wait(10).then(() => {
|
||||
return this.renderRegexp(expression);
|
||||
});
|
||||
return util.wait(10).then(() => this.renderRegexp(expression));
|
||||
}
|
||||
|
||||
this.state = 'is-loading';
|
||||
@ -225,9 +223,7 @@ export default class Regexper {
|
||||
throw message;
|
||||
})
|
||||
// When parsing is successful, render the parsed expression.
|
||||
.then(parser => {
|
||||
return parser.render();
|
||||
})
|
||||
.then(parser => parser.render())
|
||||
// Once rendering is complete:
|
||||
// - Update links
|
||||
// - Display any warnings
|
||||
|
@ -43,17 +43,15 @@ function spaceHorizontally(items, options) {
|
||||
padding: 0
|
||||
});
|
||||
|
||||
values = _.map(items, item => {
|
||||
return {
|
||||
box: normalizeBBox(item.getBBox()),
|
||||
item
|
||||
};
|
||||
});
|
||||
values = _.map(items, item => ({
|
||||
box: normalizeBBox(item.getBBox()),
|
||||
item
|
||||
}));
|
||||
|
||||
// Calculate where the axis points should be positioned vertically.
|
||||
verticalCenter = _.reduce(values, (center, { box }) => {
|
||||
return Math.max(center, box.ay);
|
||||
}, 0);
|
||||
verticalCenter = _.reduce(values,
|
||||
(center, { box }) => Math.max(center, box.ay),
|
||||
0);
|
||||
|
||||
// Position items with padding between them and aligned their axis points.
|
||||
_.reduce(values, (offset, { item, box }) => {
|
||||
@ -76,17 +74,15 @@ function spaceVertically(items, options) {
|
||||
padding: 0
|
||||
});
|
||||
|
||||
values = _.map(items, item => {
|
||||
return {
|
||||
box: item.getBBox(),
|
||||
item
|
||||
};
|
||||
});
|
||||
values = _.map(items, item => ({
|
||||
box: item.getBBox(),
|
||||
item
|
||||
}));
|
||||
|
||||
// Calculate where the center of each item should be positioned horizontally.
|
||||
horizontalCenter = _.reduce(values, (center, { box }) => {
|
||||
return Math.max(center, box.cx);
|
||||
}, 0);
|
||||
horizontalCenter = _.reduce(values,
|
||||
(center, { box }) => Math.max(center, box.cx),
|
||||
0);
|
||||
|
||||
// Position items with padding between them and align their centers.
|
||||
_.reduce(values, (offset, { item, box }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user