https://github.com/arvidkahl/sizeable
An Elixir library to make File Sizes human-readable
https://github.com/arvidkahl/sizeable
Last synced: 5 days ago
JSON representation
An Elixir library to make File Sizes human-readable
- Host: GitHub
- URL: https://github.com/arvidkahl/sizeable
- Owner: arvidkahl
- License: mit
- Created: 2016-08-17T13:31:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-19T15:49:19.000Z (8 months ago)
- Last Synced: 2024-10-14T02:44:56.093Z (6 months ago)
- Language: Elixir
- Size: 31.3 KB
- Stars: 39
- Watchers: 5
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - An Elixir library to make file sizes human-readable. (Files and Directories)
- fucking-awesome-elixir - sizeable - An Elixir library to make file sizes human-readable. (Files and Directories)
- awesome-elixir - sizeable - An Elixir library to make file sizes human-readable. (Files and Directories)
README
# Sizeable
[](https://hex.pm/packages/sizeable)
[](https://hexdocs.pm/sizeable/)
[](https://hex.pm/packages/sizeable)
[](https://github.com/arvidkahl/sizeable/blob/master/LICENSE)
[](https://github.com/arvidkahl/sizeable/commits/master)An Elixir library to make file sizes human-readable.
## Installation
The package can be installed as:
1. Add `:sizeable` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:sizeable, "~> 1.0"}
]
end
```2. Ensure `sizeable` is started before your application if you're using Elixir 1.3 or lower:
```elixir
def application do
[
applications: [:sizeable]
]
end
```## Usage
### Get file size for 1024 bytes
```elixir
Sizeable.filesize(1024)
"1 KB"
```### Get bit-sized file size for 1024 bytes
```elixir
Sizeable.filesize(1024, bits: true)
"8 Kb"
```### Get output format as list
```elixir
Sizeable.filesize(1024, output: :list)
[1, "KB"]
```### Get output format as map
```elixir
Sizeable.filesize(1024, output: :map)
%{result: 1, unit: "KB"}
```Read [Sizeable.filesize/2](https://hexdocs.pm/sizeable) for further usage details.
## Copyright and License
Copyright (c) 2016 Arvid Kahl
This software is licensed under [the MIT license](https://github.com/arvidkahl/sizeable/blob/master/LICENSE).