~mna/tulip-wiki

tulip-wiki/xio.md -rw-r--r-- 746 bytes
3ebfbd28Martin Angers Update to reflect Request:validate_body 1 year, 11 months ago

The tulip.xio module contains IO functions that extend Lua's standard io module.

#API

Assuming local xio = require 'tulip.xio'.

#s = xio.b64decode(s)

Decodes s which is a base64-encoded string using URL-safe characters. Returns nil if it was not properly encoded.

#s = xio.b64encode(s)

Encodes s into a base64 string, using URL-safe characters.

#tok = xio.random(len)

Generates a random token of the specified length.

#n = xio.randomint([n])

Generates a uniform random integer between [0, n-1]. If n is omitted, the interval is [0,2^64−1].

#s, err = xio.read_file(path)

Reads the full content of path and returns the string. On error, returns nil and the error message.

Back to index