All files name-parts.ts

100% Statements 20/20
100% Branches 5/5
100% Functions 2/2
100% Lines 20/20

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 211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 20x 20x 20x 20x 7x  
/**
 * Copyright (c) OpenLens Authors. All rights reserved.
 * Licensed under MIT License. See LICENSE in root directory for more information.
 */
 
/**
 * Split `name` into the parts seperated by one or more of (-, _, or .) and
 * the sections can be converted to numbers will be converted
 * @param name A kube object name
 * @returns The converted parts of the name
 */
export function getConvertedParts(name: string): (string | number)[] {
  return name
    .split(/[-_./\\]+/)
    .map(part => {
      const converted = +part;
 
      return isNaN(converted) ? part : converted;
    });
}