bytes-convert
    TypeScript icon, indicating that this package has built-in type declarations

    4.7.0 • Public • Published

    bytes-convert

    Release

    A simple JavaScript module to convert bits to either bytes or octet.

    Usage

    In Node.js

    const bytesConvert = require('bytes-convert');
    
    bytesConvert.convertFromOctet(65631);
    // '65.63Ko'
    
    bytesConvert.convertFromBits(6563123);
    // '820.39Ko'
    
    // OR
    
    import { convertFromOctet, convertFromBits, Units } from 'bytes-convert';
    
    convertFromOctet(65631);
    convertFromOctet(65631, Units.OCTET);
    // '65.63Ko'
    convertFromOctet(65631, Units.BYTE);
    // '6.56MB'
    
    convertFromBits(6563123);
    convertFromBits(6563123, Units.OCTET);
    // '820.39Ko'
    convertFromBits(6563123, Units.BYTE);
    // '820.39KB'

    In browser

    <script src="https://cdn.jsdelivr.net/npm/bytes-convert/dist/bytes-convert.umd.min.js"></script>
    
    <script>
        bytesConvert.convertFromOctet(65631);
        // '65.63Ko'
        
        bytesConvert.convertFromBits(6563123);
        // '820.39Ko'
    </script>

    Install

    npm i bytes-convert

    DownloadsWeekly Downloads

    71

    Version

    4.7.0

    License

    GPL-3.0

    Unpacked Size

    42.7 kB

    Total Files

    13

    Last publish

    Collaborators

    • hy0ug0