Skip to content

Commit

Permalink
http, readline: replace sort with toSorted
Browse files Browse the repository at this point in the history
PR-URL: #53623
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
benjamingr authored and aduh95 committed Jul 16, 2024
1 parent 0f95ad3 commit b13aea5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/internal/readline/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

const {
ArrayPrototypeSlice,
ArrayPrototypeSort,
ArrayPrototypeToSorted,
RegExpPrototypeExec,
StringFromCharCode,
StringPrototypeCharCodeAt,
Expand Down Expand Up @@ -385,7 +384,7 @@ function commonPrefix(strings) {
if (strings.length === 1) {
return strings[0];
}
const sorted = ArrayPrototypeSort(ArrayPrototypeSlice(strings));
const sorted = ArrayPrototypeToSorted(strings);
const min = sorted[0];
const max = sorted[sorted.length - 1];
for (let i = 0; i < min.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions typings/primordials.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ declare namespace primordials {
export const ArrayPrototypeSlice: UncurryThis<typeof Array.prototype.slice>
export const ArrayPrototypeSort: UncurryThis<typeof Array.prototype.sort>
export const ArrayPrototypeSplice: UncurryThis<typeof Array.prototype.splice>
export const ArrayPrototypeToSorted: UncurryThis<typeof Array.prototype.toSorted>
export const ArrayPrototypeIncludes: UncurryThis<typeof Array.prototype.includes>
export const ArrayPrototypeIndexOf: UncurryThis<typeof Array.prototype.indexOf>
export const ArrayPrototypeJoin: UncurryThis<typeof Array.prototype.join>
Expand Down

0 comments on commit b13aea5

Please sign in to comment.