Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

工作日常 2018/11/28 #5

Open
Link-Fight opened this issue Nov 28, 2018 · 0 comments
Open

工作日常 2018/11/28 #5

Link-Fight opened this issue Nov 28, 2018 · 0 comments
Labels

Comments

@Link-Fight
Copy link
Owner

Link-Fight commented Nov 28, 2018

发现问题

  • 在试用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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant