Skip to content

工作日常 2018/11/28 #5

Open
@Link-Fight

Description

@Link-Fight

发现问题

  • 在试用nedtior时发现通过registerUIapi来注册自定义按钮有问题,所以提了issue

阅读学习

Good codes

  • 传入文件的大小(bit),然后返回其它单位下的文件大小
function getFileSizeFormat(nBytes) {
  var sOutput = nBytes + " bytes";
  for (var aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"], nMultiple = 0, nApprox = nBytes / 1024; nApprox > 1; nApprox /= 1024, nMultiple++) {
    sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)";
  }
  return sOutput
}

getFileSizeFormat(11111112048) => 10.348 GiB (11111112048 bytes)
getFileSizeFormat(1112048) => 1.061 MiB (1112048 bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions