react-pretty-bytes

Convert bytes to a human readable string


Keywords
yohix, react, react native, humanizer, humanize bytes, pretty bytes, bytes, converter, node-module, npm, prettify, react-native
License
MIT
Install
npm install react-pretty-bytes@1.0.2

Documentation

React Pretty Bytes

Convert bytes to a human readable string 1337 → 1.34 kB

CI Version Downloads Install size

NPM

Try in CodeSandbox

Edit react-camelcase

Install

$ npm install react-pretty-bytes

Usage

import PrettyBytes from 'react-pretty-bytes';

const App = () => (
  <div>
    <PrettyBytes bytes={1337} />
  </div>
);

// => '1.34 kB'

API

bytes={input}

Type: integer

<PrettyBytes bytes={1337} />

// => '1.34 kB'

option={object}

Type: object

{bits: true}

Type: boolean Default: false

<PrettyBytes bytes={1337} option={{bits: true}} />

// => '1.34 kbit'

{signed: true}

Type: boolean Default: false

<PrettyBytes bytes={1337} option={{signed: true}} />

// => '+42 B'

{locale: 'lang'}

Type: boolean string Default: false

<PrettyBytes bytes={1337} option={{locale: 'de'}} />

// => '1,34 kB'

Modules used

License

MIT © Yohix