An Elixir library to make file sizes human-readable.
The package can be installed as:
-
Add
:sizeableto your list of dependencies inmix.exs:def deps do [ {:sizeable, "~> 1.0"} ] end
-
Ensure
sizeableis started before your application if you're using Elixir 1.3 or lower:def application do [ applications: [:sizeable] ] end
Sizeable.filesize(1024)
"1 KB"Sizeable.filesize(1024, bits: true)
"8 Kb"Sizeable.filesize(1024, output: :list)
[1, "KB"]Sizeable.filesize(1024, output: :map)
%{result: 1, unit: "KB"}Read Sizeable.filesize/2 for further usage details.
Copyright (c) 2016 Arvid Kahl
This software is licensed under the MIT license.