jsonnet-compose/compose.libsonnet

20 lines
388 B
Plaintext

// the tail of an array
local tail(array) = std.makeArray(
std.length(array) -1,
function(x) array[x + 1],
);
local compose(functions) =
if std.length(functions) == 0
then
function(object) object
else
function(object) compose(
tail(
functions,
)
)(
functions[0](object)
);
// compose an array of functions
compose