@util

Home of the ABS programming language: the joy of shell scripting.


@util

The @util module provides various utilities.

API

util = require('@util')

@util.memoize(ttl)

A decorator that allows memoization of a function based on the arguments passed to it:

@util.memoize(60)
f expensive_task(x, y, z) {
    # do something very expensive here...
}

The first time expensive_task gets called with a set of arguments, it will be execute. The next time it’s called with the same set of arguments its result will be fetched from a cache (currently implemented in-memory). Executions are going to be cached for a specific timeframe, ttl (in seconds).

Arguments are serialized using the str() method:

[12, {}, 0.23, "hello"].str() # "[12, {}, 0.23, \"hello\"]"

Next

That’s about it for this section!

You can now head over to read a little bit about how to install 3rd party libraries.