augment-vir - v32.7.0
    Preparing search index...

    Function convertByteSize

    • Converts a storage size from any combination of units into the selected units. Same as date-vir's convertDuration: the total is split from the largest selected unit down, every unit but the smallest gets a whole number, and the smallest selected unit gets the unrounded remainder.

      Type Parameters

      Parameters

      Returns ByteSizeBySelection<Selection>

      import {convertByteSize} from '@augment-vir/common';

      // `result1` is `{bytes: 10_485_760}`
      const result1 = convertByteSize({megabytes: 10}, {bytes: true});
      // `result2` is `{gigabytes: 1.5}`
      const result2 = convertByteSize({gigabytes: 1, megabytes: 512}, {gigabytes: true});
      // `result3` is `{gigabytes: 1, megabytes: 512}`
      const result3 = convertByteSize({megabytes: 1536}, {gigabytes: true, megabytes: true});