From fd21dd45d56ed8f3e202dc0aef92378519551b64 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Wed, 10 Jul 2024 19:46:24 +0300 Subject: [PATCH] http, readline: replace sort with toSorted PR-URL: https://github.com/nodejs/node/pull/53623 Reviewed-By: Yagiz Nizipli Reviewed-By: Richard Lau Reviewed-By: Tim Perry Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow Reviewed-By: Matteo Collina Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- lib/internal/readline/utils.js | 5 ++--- typings/primordials.d.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index 124a5382a0ddae..4a6845af4241da 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -1,8 +1,7 @@ 'use strict'; const { - ArrayPrototypeSlice, - ArrayPrototypeSort, + ArrayPrototypeToSorted, RegExpPrototypeExec, StringFromCharCode, StringPrototypeCharCodeAt, @@ -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++) { diff --git a/typings/primordials.d.ts b/typings/primordials.d.ts index ce6ca86f3e633d..e5426b85b5c29b 100644 --- a/typings/primordials.d.ts +++ b/typings/primordials.d.ts @@ -128,6 +128,7 @@ declare namespace primordials { export const ArrayPrototypeSlice: UncurryThis export const ArrayPrototypeSort: UncurryThis export const ArrayPrototypeSplice: UncurryThis + export const ArrayPrototypeToSorted: UncurryThis export const ArrayPrototypeIncludes: UncurryThis export const ArrayPrototypeIndexOf: UncurryThis export const ArrayPrototypeJoin: UncurryThis