All files / src/utils/common singleton.ts

100% Statements 2/2
100% Branches 1/1
100% Functions 1/1
100% Lines 2/2

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      1x                     1x  
/**
 * A singleton array that is used to represent an empty array.
 */
export const EMPTY_ARRAY: readonly unknown[] = Object.freeze([]);
 
/**
 * A function that returns a singleton array that is used to represent an empty array.
 *
 * @example:
 * ```ts
 * const emptyArray = emptyArray<number>();
 * console.log(emptyArray); // []
 * ```
 */
export const emptyArray = <T>(): readonly T[] => EMPTY_ARRAY as readonly T[];