File tree 1 file changed +2
-2
lines changed 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -1077,7 +1077,7 @@ namespace ts {
1077
1077
* Returns the first element of an array if non-empty, `undefined` otherwise.
1078
1078
*/
1079
1079
export function firstOrUndefined < T > ( array : ReadonlyArray < T > ) : T | undefined {
1080
- return elementAt ( array , 0 ) ;
1080
+ return array . length === 0 ? undefined : array [ 0 ] ;
1081
1081
}
1082
1082
1083
1083
export function first < T > ( array : ReadonlyArray < T > ) : T {
@@ -1089,7 +1089,7 @@ namespace ts {
1089
1089
* Returns the last element of an array if non-empty, `undefined` otherwise.
1090
1090
*/
1091
1091
export function lastOrUndefined < T > ( array : ReadonlyArray < T > ) : T | undefined {
1092
- return elementAt ( array , - 1 ) ;
1092
+ return array . length === 0 ? undefined : array [ array . length - 1 ] ;
1093
1093
}
1094
1094
1095
1095
export function last < T > ( array : ReadonlyArray < T > ) : T {
You can’t perform that action at this time.
0 commit comments