humanize

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

README

humanize GoDoc

Usage

local humanize = require("humanize")
local time = require("time")

-- humanize.parse_bytes
local size, err = humanize.parse_bytes("1.3GiB")
if err then error(err) end
if not(size == 1395864371) then error("size: "..tostring(size)) end

-- humanize.ibytes
local size_string = humanize.ibytes(1395864371)
if not(size_string == "1.3 GiB") then error("ibytes: "..size_string) end

-- humanize.time
local t = time.unix() - 2
local time_string = humanize.time(t)
if not(time_string == "2 seconds ago") then error("time: "..time_string) end

-- humanize.si
local si_result = humanize.si(0.212121, "m")
if not(si_result == "212.121 mm") then error("si: "..tostring(si_result)) end

Documentation

Overview

Port dustin/go-humanize for gopher-lua

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IBytes

func IBytes(L *lua.LState) int

IBytes lua humanize.ibytes(number) return string

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func ParseBytes

func ParseBytes(L *lua.LState) int

ParseBytes lua humanize.parse_bytes(string) returns (number, err)

func Preload

func Preload(L *lua.LState)

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

func SI(L *lua.LState) int

SI lua humanize.si(number, string) return string

func Time

func Time(L *lua.LState) int

Time lua humanize.time(number) return string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL