github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/pages/adhoc/components/humanize.ts (about)

     1  /* eslint-disable default-case, consistent-return */
     2  import { UnitsType } from '@pyroscope/models/src';
     3  import { SpyNameFirstClassType } from '@pyroscope/models/src/spyName';
     4  
     5  export const humanizeSpyname = (n: SpyNameFirstClassType) => {
     6    switch (n) {
     7      case 'gospy':
     8        return 'Go';
     9      case 'pyspy':
    10        return 'Python';
    11      case 'phpspy':
    12        return 'PHP';
    13      case 'pyroscope-rs':
    14        return 'Rust';
    15      case 'dotnetspy':
    16        return '.NET';
    17      case 'ebpfspy':
    18        return 'eBPF';
    19      case 'rbspy':
    20        return 'Ruby';
    21      case 'nodespy':
    22        return 'NodeJS';
    23      case 'javaspy':
    24        return 'Java';
    25    }
    26  };
    27  
    28  export const humanizeUnits = (u: UnitsType) => {
    29    switch (u) {
    30      case 'samples':
    31        return 'Samples';
    32      case 'objects':
    33        return 'Objects';
    34      case 'goroutines':
    35        return 'Goroutines';
    36      case 'bytes':
    37        return 'Bytes';
    38      case 'lock_samples':
    39        return 'Lock Samples';
    40      case 'lock_nanoseconds':
    41        return 'Lock Nanoseconds';
    42      case 'trace_samples':
    43        return 'Trace Samples';
    44      case 'exceptions':
    45        return 'Exceptions';
    46    }
    47  };
    48  
    49  export const isJSONFile = (file: File) =>
    50    file.name.match(/\.json$/) ||
    51    file.type === 'application/json' ||
    52    file.type === 'text/json';