amelinium.utils

added in 1.0.0

amelinium service, utility functions.

empty-lazy-map

An empty lazy map.

keyword-from-param

(keyword-from-param s)

Takes a value s (which should be convertable to a keyword) and returns a keyword with a name having first colon character removed in pre-parsing phase. Returns nil for falsy values or empty strings (including empty strings after trimming the :).

random-uuid-or-empty

(random-uuid-or-empty)(random-uuid-or-empty rng)

Returns random UUID object or an empty string (50/50 chance).

retry-in-mins

(retry-in-mins duration)

Calculates minutes of duration on a basis of Duration object. Returns an integer number of minutes left or nil when there was no duration given or the duration is negative. May return 0 if there is less than 1 minute left. Used to calculate retry timeouts to report them to a user.

rfc1123-date-time

(rfc1123-date-time t)

Returns a date and time formatted according to the RFC 1123.

simple-duration

(simple-duration end)(simple-duration begin end)

Calculates the duration between the time of calling the function (or the given time begin) till the given time end, with nanoseconds set to 0.

some-resource

(some-resource path)(some-resource path & more)

Returns the given path if there is a resource it points to. Otherwise it returns nil. Multiple arguments are joined using str.

string-from-param

(string-from-param s)

Takes a value s (which should be convertable to a string) and returns a string with first colon character removed. Returns nil for falsy values or empty string (including empty strings after trimming the :).

timeout?

(timeout? duration)

Returns true if the given duration is negative or 0, false otherwise. Uses milliseconds. Returns false when nil or false is given.

try-name

(try-name v)

If the given v is an ident, it returns its name. Otherwise it returns v.

try-namespace

(try-namespace v)

If the given v is an ident, it returns its namespace. Otherwise it returns v.