Apply suggestions from code review

Co-authored-by: Marc Durdin <marc@durdin.net>
This commit is contained in:
Steven R. Loomis 2023-07-03 18:20:20 -05:00 committed by GitHub
parent a25d3819d1
commit a6dcf4dfce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ export class ElemElement {
export class ElementString extends Array<ElemElement> {
/**
* @param source if a string array, does not get reinterpreted as UnicodeSet. This is used with vars, etc. Or pass `["str"]` for an explicit 1-element elem.
* If it is a string, will be interpreted per reorder element ruls.
* If it is a string, will be interpreted per reorder element rules.
*/
constructor(sections: DependencySections, source: string | string[], order?: string, tertiary?: string, tertiary_base?: string, prebase?: string) {
super();
@ -38,9 +38,8 @@ export class ElementString extends Array<ElemElement> {
return;
}
const sourceIsArray = Array.isArray(source);
let items : ElementSegment[];
if (sourceIsArray) {
if (Array.isArray(source)) {
items = source.map(segment => new ElementSegment(segment, ElementType.string));
} else {
// use segmenter to analyze each part