All files / src utilities.js

100% Statements 12/12
100% Branches 8/8
100% Functions 6/6
100% Lines 8/8

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48        371x 10x 238x 76x           1x 66x                             1x 89x                                  
// --------------------------------------
// Common Core - Utility Functions
// --------------------------------------
 
export const lasti = (a) => a[a.length - 1];
export const stringify = (v) => v && v.toString ? v.toString() : `${v}`;
export const hasSubstr = (s, sub) => s.indexOf(sub) !== -1;
export const getYesNo = (v) => v === 'Yes' ? true : v === 'No' ? false : undefined;
 
// --------------------------------------
// Common Core - Empty FS Objects
// --------------------------------------
 
export const emptyDevice = () => {
  return {
    id: null,
    node: null,
    whole: false,
    parent: null,
    name: null,
    size: null,
    description: null,
    protocol: null,
    blockSize: null,
    readOnly: null,
    removable: null,
  };
};
 
export const emptyVolume = () => {
  return {
    id: null,
    node: null,
    whole: false,
    parent: null,
    name: null,
    description: null,
    blockSize: null,
    blocks: null,
    readOnly: null,
    mounted: null,
    mountPoint: null,
    partitionType: null,
    fs: null,
    space: { total: null, available: null, used: null },
  };
};