diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-10-15 13:56:54 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-10-15 13:56:54 -0300 |
commit | 84a98b3b71d5524baf7b5e9038909ad501203115 (patch) | |
tree | e9702cbdefd19ac7259e4b9d918709fcd62fcfd0 /src | |
parent | 74bd087bb01c759b1bf38c9bc445e42b43684276 (diff) |
toReversed, toSorted miscellany
Diffstat (limited to 'src')
-rw-r--r-- | src/content-function.js | 2 | ||||
-rw-r--r-- | src/content/dependencies/generateWikiHomepageAlbumGridRow.js | 3 | ||||
-rw-r--r-- | src/data/composite.js | 2 | ||||
-rw-r--r-- | src/data/things/sorting-rule.js | 8 | ||||
-rw-r--r-- | src/static/js/client/sticky-heading.js | 2 |
5 files changed, 7 insertions, 10 deletions
diff --git a/src/content-function.js b/src/content-function.js index f3aa7c42..1144a7b9 100644 --- a/src/content-function.js +++ b/src/content-function.js @@ -286,7 +286,7 @@ export const decorateErrorWithRelationStack = (fn, traceStack) => decorateError(fn, caughtError => { let cause = caughtError; - for (const {name, args, traceError} of traceStack.slice().reverse()) { + for (const {name, args, traceError} of traceStack.toReversed()) { const nameText = colors.green(`"${name}"`); const namePart = `Error in relation(${nameText})`; diff --git a/src/content/dependencies/generateWikiHomepageAlbumGridRow.js b/src/content/dependencies/generateWikiHomepageAlbumGridRow.js index 6d167bdd..eb3417d7 100644 --- a/src/content/dependencies/generateWikiHomepageAlbumGridRow.js +++ b/src/content/dependencies/generateWikiHomepageAlbumGridRow.js @@ -18,8 +18,7 @@ export default { sprawl.albums = (row.sourceGroup ? row.sourceGroup.albums - .slice() - .reverse() + .toReversed() .filter(album => album.isListedOnHomepage) .slice(0, row.countAlbumsFromGroup) : []); diff --git a/src/data/composite.js b/src/data/composite.js index f31c4069..e5873cf5 100644 --- a/src/data/composite.js +++ b/src/data/composite.js @@ -1416,7 +1416,7 @@ export function compositeFrom(description) { export function displayCompositeCacheAnalysis() { const showTimes = (cache, key) => { - const times = cache.times[key].slice().sort(); + const times = cache.times[key].toSorted(); const all = times; const worst10pc = times.slice(-times.length / 10); diff --git a/src/data/things/sorting-rule.js b/src/data/things/sorting-rule.js index 808a0085..8ed3861a 100644 --- a/src/data/things/sorting-rule.js +++ b/src/data/things/sorting-rule.js @@ -146,7 +146,7 @@ export class ThingSortingRule extends SortingRule { sort(sortable) { if (this.properties) { - for (const property of this.properties.slice().reverse()) { + for (const property of this.properties.toReversed()) { const get = thing => thing[property]; const lc = property.toLowerCase(); @@ -286,10 +286,8 @@ export class DocumentSortingRule extends ThingSortingRule { } static async* applyAll(rules, {wikiData, dataPath, dry}) { - rules = - rules - .slice() - .sort((a, b) => a.filename.localeCompare(b.filename, 'en')); + rules = rules + .toSorted((a, b) => a.filename.localeCompare(b.filename, 'en')); for (const {chunk, filename} of chunkByProperties(rules, ['filename'])) { const initialLayout = getThingLayoutForFilename(filename, wikiData); diff --git a/src/static/js/client/sticky-heading.js b/src/static/js/client/sticky-heading.js index 4660013a..1318ca0b 100644 --- a/src/static/js/client/sticky-heading.js +++ b/src/static/js/client/sticky-heading.js @@ -255,7 +255,7 @@ function getContentHeadingClosestToStickySubheading(index) { // Iterate from bottom to top of the content area. const contentHeadings = info.contentHeadings[index]; - for (const heading of contentHeadings.slice().reverse()) { + for (const heading of contentHeadings.toReversed()) { if (heading.nodeName === 'SUMMARY' && !heading.closest('details').open) { continue; } |