All files / common/helpers track-by.helper.ts

62.5% Statements 5/8
100% Branches 0/0
25% Functions 1/4
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34            1x                       33x   1x                       1x  
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { TrackByFunction } from '@angular/core';
 
const trackByIdentity = <T>(index: number, item: T): any => item;
 
/**
 * Creates a trackByFunction for ngFor, that tracks an Item by its identity.
 * It should be used with a generic parameter, to generate a proper type:
 *
 * @example
 * ```ts
 * @Input() trackByFunction = buildTrackByIdentity<ItemType>()
 * ```
 * @deprecated use the new control-flow syntax
 */
export const buildTrackByIdentity = <T>(): TrackByFunction<T> => trackByIdentity;
 
const trackByIndex = (index: number): number => index;
 
/**
 * Creates a trackByFunction for ngFor, that tracks an Item by its index.
 * It should be used with a generic parameter, to generate a proper type:
 *
 * @example
 * ```
 * @Input() trackByFunction = buildTrackByIdentity<ItemType>()
 * ```
 * @deprecated use the new control-flow syntax
 */
export const buildTrackByIndex = <T>(): TrackByFunction<T> => trackByIndex;