Documentation
¶
Overview ¶
Port dustin/go-humanize for gopher-lua
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IBytes ¶
IBytes lua humanize.ibytes(number) return string
Example ¶
humanize.ibytes(number)
state := lua.NewState() Preload(state) source := ` local humanize = require("humanize") print(humanize.ibytes(1395864371)) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 1.3 GiB
func ParseBytes ¶
ParseBytes lua humanize.parse_bytes(string) returns (number, err)
Example ¶
humanize.parse_bytes(string)
state := lua.NewState() Preload(state) source := ` local humanize = require("humanize") print(humanize.parse_bytes("1.3GiB")) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 1395864371
func Preload ¶
Preload adds humanize to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:
local humanize = require("humanize")
func SI ¶
SI lua humanize.si(number, string) return string
Example ¶
humanize.si(input, unit)
state := lua.NewState() Preload(state) source := ` local humanize = require("humanize") print(humanize.si(0.212121, "m")) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 212.121 mm
func Time ¶
Time lua humanize.time(number) return string
Example ¶
humanize.time(number)
state := lua.NewState() Preload(state) time.Preload(state) source := ` local humanize = require("humanize") local time = require("time") print(humanize.time(time.unix() - 61)) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 1 minute ago
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.