Skip to content

Commit

Permalink
refactor: simplify any/all isNA checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gadenbuie committed Dec 5, 2023
1 parent b7f100e commit 22e7147
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
12 changes: 5 additions & 7 deletions inst/components/dist/web-components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/components/dist/web-components.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions inst/components/dist/web-components.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/components/dist/web-components.min.js.map

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions srcts/src/components/webcomponents/layoutColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,18 @@ export class BslibLayoutColumns extends HTMLElement {
* @returns The resolved column width specification.
*/
private _resolveColWidthsSpec(): BreakpointColumnSpec {
const allResolved = Array.from(this.colWidths.values()).every(
(val) => !isNA(val)
);
const colValuesNA = Array.from(this.colWidths.values()).map(isNA);

if (allResolved) {
const all = (x: boolean[]) => x.every((val: boolean) => val === true);
const any = (x: boolean[]) => x.some((val: boolean) => val === true);

if (!any(colValuesNA)) {
return newBreakpointColumnSpec(this.colWidths as BreakpointMapResolved);
}

const resolved = new Map() as BreakpointMapResolved;

const allAutoFit = Array.from(this.colWidths.values()).every((val) =>
isNA(val)
);

const allAutoFit = all(colValuesNA);
const units = allAutoFit ? null : 12;
const nChildren = this.children.length;

Expand Down

0 comments on commit 22e7147

Please sign in to comment.