GeezerVison is showing github.com — http, readline: replace sort with toSorted · nodejs/node@b13aea5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/readline/utils.js +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const { |
4 | | - ArrayPrototypeSlice, |
5 | | - ArrayPrototypeSort, |
| 4 | + ArrayPrototypeToSorted, |
6 | 5 | RegExpPrototypeExec, |
7 | 6 | StringFromCharCode, |
8 | 7 | StringPrototypeCharCodeAt, |
@@ -385,7 +384,7 @@ function commonPrefix(strings) { |
385 | 384 | if (strings.length === 1) { |
386 | 385 | return strings[0]; |
387 | 386 | } |
388 | | - const sorted = ArrayPrototypeSort(ArrayPrototypeSlice(strings)); |
| 387 | + const sorted = ArrayPrototypeToSorted(strings); |
389 | 388 | const min = sorted[0]; |
390 | 389 | const max = sorted[sorted.length - 1]; |
391 | 390 | for (let i = 0; i < min.length; i++) { |
|
Collapse file
Copy file name to clipboardExpand all lines: typings/primordials.d.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -128,6 +128,7 @@ declare namespace primordials { |
128 | 128 | export const ArrayPrototypeSlice: UncurryThis<typeof Array.prototype.slice> |
129 | 129 | export const ArrayPrototypeSort: UncurryThis<typeof Array.prototype.sort> |
130 | 130 | export const ArrayPrototypeSplice: UncurryThis<typeof Array.prototype.splice> |
| 131 | + export const ArrayPrototypeToSorted: UncurryThis<typeof Array.prototype.toSorted> |
131 | 132 | export const ArrayPrototypeIncludes: UncurryThis<typeof Array.prototype.includes> |
132 | 133 | export const ArrayPrototypeIndexOf: UncurryThis<typeof Array.prototype.indexOf> |
133 | 134 | export const ArrayPrototypeJoin: UncurryThis<typeof Array.prototype.join> |
|