Skip to content

Commit 245b4a3

Browse files
committed
chore: use es2023 toSorted()
1 parent 6fd9a79 commit 245b4a3

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/generators/jsx-ast/utils/getSortedHeadNodes.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ const headingSortFn = (a, b) => {
3333
* @returns {Array<ApiDocMetadataEntry>}
3434
*/
3535
export const getSortedHeadNodes = entries =>
36-
entries.filter(node => node.heading.depth === 1).sort(headingSortFn);
36+
entries.filter(node => node.heading.depth === 1).toSorted(headingSortFn);

src/generators/legacy-html/index.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ export default {
113113

114114
const headNodes = input
115115
.filter(node => node.heading.depth === 1)
116-
.sort((a, b) => a.heading.data.name.localeCompare(b.heading.data.name));
116+
.toSorted((a, b) =>
117+
a.heading.data.name.localeCompare(b.heading.data.name)
118+
);
117119

118120
const indexOfFiles = index
119121
? index.map(({ api, section }) => ({ api, heading: getHeading(section) }))

src/generators/legacy-json-all/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default {
5555
);
5656

5757
// Sort input by index order (documents not in index go to the end)
58-
const sortedInput = [...input].sort((a, b) => {
58+
const sortedInput = input.toSorted((a, b) => {
5959
const aOrder = indexOrder.get(a.source) ?? Infinity;
6060
const bOrder = indexOrder.get(b.source) ?? Infinity;
6161

src/utils/generators.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const getCompatibleVersions = (introduced, releases) => {
8989
*/
9090
export const sortChanges = (changes, key = 'version') => {
9191
// Sorts the updates and changes by the first version on a given entry
92-
return changes.sort((a, b) => {
92+
return changes.toSorted((a, b) => {
9393
const aVersion = Array.isArray(a[key]) ? a[key][0] : a[key];
9494
const bVersion = Array.isArray(b[key]) ? b[key][0] : b[key];
9595

0 commit comments

Comments
 (0)