Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.3 KB

README.md

File metadata and controls

51 lines (36 loc) · 1.3 KB

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>