`
niwtsew
  • 浏览: 70793 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Convert size in bytes to human readable format

 
阅读更多

http://codeaid.net/javascript/convert-size-in-bytes-to-human-readable-format-(javascript)

 

 

function bytesToSize (bytes) {
var sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return ((i == 0)? (bytes / Math.pow(1024, i)) : (bytes / Math.pow(1024, i)).toFixed(1)) + ' ' + sizes[i];
};

分享到:
评论

相关推荐

    human-readable-number

    人类可读号码任务您的任务是实现toReadable...%your_github_username%> / human-visible-number / 转到文件夹“ human-readable-number 要安装所有依赖项,请使用 在命令行中运行npm test 您会看到通过和未通过测试的

    humanreadable:人工可读的Python库,可将人工可读的值转换为不同的单位

    支持的单位时间(天,小时,分钟,秒等) 每秒位数 用法 基本用法样例代码: import humanreadable as hrprint ( " \n [Examples: humanreadable.Time]" )value = "120 sec"print ( "'{}' to msecs -> {}" . format...

    json-log-to-human-readable

    支持以下格式:Flags: -d, --dotnet .NET JSON input -h, --help help for json-log-to-human-readable -s, --springboot Spring Boot JSON input -v, --version version for json-log-to-human-readable -z, --zap...

    utc.tar.gz_UTC_human_unix to utc

    标题“utc.tar.gz_UTC_human_unix_to_utc”和描述“UTC format to human readable format”指出,这个压缩包可能包含一个程序或工具,用于将协调世界时间(UTC)格式转换为人类可读的时间格式。在IT领域,时间戳通常...

    SUPTOOL CONV - Convert HEX DUMP or BLOCKDUMP to readable form (Doc ID 47419.1)

    ### SUPTOOL CONV - 转换HEX DUMP或BLOCKDUMP为可读形式 #### 知识点概述: SUPTOOL CONV是一款由Oracle开发的专业工具,其主要功能是将原始的HEX DUMP或Oracle BLOCK DUMP转换成人类可读的形式。...

    Practical Statistics for Data Scientists: 50 Essential Concepts

    Practical Statistics for Data Scientists: 50 Essential Concepts by Peter Bruce, Andrew Bruce English | ISBN: 1491952962 |... This quick reference book bridges that gap in an accessible, readable format.

    Human readable Glassfish Log-开源

    hgl的全称可能是"Human-readable Glassfish Log",它能实时解析`server.log`文件,将复杂的日志信息转化为清晰、简洁的文本输出,使得非技术人员也能轻松理解。通过hgl,用户可以快速定位问题,跟踪服务器的运行状况...

    Numerical Methods using MATLAB Apress 2014

    Numerical Methods with MATLAB presents each topic in a concise and readable format to help you learn fast and effectively. It is not intended to be a reference work to the conceptual theory that ...

    random-bytes-readable-stream:使用`crypto.randomBytes()`创建一个可读流,以产生具有加密强度的伪随机数据。

    安装 $ npm install random-bytes-readable-stream用法 const randomBytesReadableStream = require ( 'random-bytes-readable-stream' ) ;randomBytesReadableStream ( { size : 10 } ) . pipe ( process . stdout ...

    USB Billboard Revision 1.2.2 - CLEAN.pdf

    This includes string descriptors that can be used to provide support details in a human-readable format. This specification does not describe the functionality/methodology by which the Device ...

    cortex M3反汇编

    CORTEX M3 disassembler 反汇编 工具 DESCRIPTION mdisasm is basic disassembler for Cortex M0/M3 cores, which can be found in STM32, LPC 1xxx and ... Show address in [pc, imm] format in ldr instructions

    hudson1.293.part1.rar

    Improved the access denied error message to be more human readable. (report) What's new in 1.291 api/xml?xpath=...&wrapper=... behaved inconsistently for results of size 0 or 1. (issue 3267) Fixed ...

    to-readable-stream:将stringBufferUint8Array转换为可读流

    $ npm install to-readable-stream 用法 import toReadableStream from 'to-readable-stream' ; toReadableStream ( ':unicorn::rainbow:' ) . pipe ( process . stdout ) ; 原料药 toReadableStream(值) 返回一...

    Human Readable Timestamps!-crx插件

    语言:English (United States) 可读的日期字符串替换了单击时的时间戳 易于阅读的日期字符串,只需单击一下即可替换页面中的所有时间戳,而无需转到控制台,并从历元复制粘贴到每个日期的新Date().......

    人类可读的时间戳!「Human Readable Timestamps!」-crx插件

    人类可读的日期字符串替换了单击的时间戳。 易于阅读的日期字符串,只需单击一下即可替换页面中的所有时间戳,而无需转到控制台,并从历元复制粘贴到每个日期的新Date()....再次单击,然后切换回去,以便您可以...

    Introduction to Algorithms Third Edition

    Algorithms are described in English and in a pseudocode designed to be readable by anyone who has done a little programming. The book contains 244 figures—many with multiple parts—illustrating how ...

    dist-size打印目录中文件的大小

    默认格式是`human-readable`,它会以人类可读的KB、MB、GB单位显示大小。你也可以选择`json`格式,以便更方便地在其他脚本中处理输出。 在实际开发中,`dist-size`可以结合构建工具如Webpack、Rollup等一起使用,...

    Introduction.To.Algorithms,.Second.Edition

    Algorithms are described in English and in a "pseudocode" designed to be readable by anyone who has done a little programming. The book contains over 230 figures illustrating how the algorithms work. ...

Global site tag (gtag.js) - Google Analytics