Sha256: db65044fc5bfe76ff4ab102b5c418c67e4ffb93409c94c7ba741145de83bfce5

Contents?: true

Size: 319 Bytes

Versions: 28

Compression:

Stored size: 319 Bytes

Contents

export function formatFileSize(bytes) {
  let exponent = bytes === 0 ? 0 : Math.floor(Math.log(bytes) / Math.log(1024))

  // prevent format higher than GB
  if (exponent > 3) {
    exponent = 3
  }

  let value = (bytes / Math.pow(1024, exponent)).toFixed(2)
  return value + " " + ["B", "kB", "MB", "GB"][exponent]
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
alchemy_cms-7.3.4 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.3.3 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.3.2 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.7 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.3.1 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.3.0 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.6 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.5 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.4 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.3 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.2 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.2.1 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.7 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.6 app/javascript/alchemy_admin/utils/format.js
alchemy_cms-7.1.5 app/javascript/alchemy_admin/utils/format.js