Skip to content

Commit

Permalink
fix sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
wz2cool committed Mar 1, 2019
1 parent ece5ef7 commit a2b40ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/array.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ export class ArrayUtils {
*/
public static takeRight<T>(array: T[], n?: number | undefined | null): T[] {
const length = array.length;
let useStartIndex;
if (ObjectUtils.isNullOrUndefined(n) || isNaN(n!)) {
let useStartIndex: number;
if (ObjectUtils.isNullOrUndefined(n) || isNaN(n)) {
// default value is 1
useStartIndex = length - 1;
} else if (n! < 0) {
} else if (n < 0) {
useStartIndex = length;
} else if (n! < length) {
useStartIndex = length - n!;
} else if (n < length) {
useStartIndex = length - n;
} else {
useStartIndex = 0;
}
Expand Down

0 comments on commit a2b40ab

Please sign in to comment.