https://github.com/james2doyle/lit-pretty-bytes
Lit package for converting bytes to a human readable string: 1337 → 1.34 kB
https://github.com/james2doyle/lit-pretty-bytes
Last synced: 6 months ago
JSON representation
Lit package for converting bytes to a human readable string: 1337 → 1.34 kB
- Host: GitHub
- URL: https://github.com/james2doyle/lit-pretty-bytes
- Owner: james2doyle
- License: mit
- Created: 2015-03-12T01:46:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-06T22:59:54.000Z (over 10 years ago)
- Last Synced: 2025-01-07T08:49:11.724Z (over 1 year ago)
- Language: Lua
- Size: 152 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Pretty Bytes
=============
[sindresorhus/pretty-bytes npm package](https://github.com/sindresorhus/pretty-bytes)
> Convert bytes to a human readable string: `1337` → `1.34 kB`
Useful for displaying file sizes for humans.
---
*Note that it uses base-10 (eg. kilobyte). [Read about the difference between kilobyte and kibibyte.](http://pacoup.com/2009/05/26/kb-kb-kib-whats-up-with-that/)*
## Install
```sh
$ lit install james2doyle/pretty-bytes
```
## Usage
```lua
local prettyBytes = require('pretty-bytes')
print(prettyBytes(1337)) -- prints 1.34kB
-- a byte < 1 example
print(prettyBytes(0.1337)) -- prints 0.1337 B
-- passing true as last argument adds a single space between number and size
print(prettyBytes(1337, true)) -- prints 1.34 kB
```