jsonnet-compose/compose.libsonnet

20 lines
388 B
Plaintext
Raw Permalink Normal View History

2020-07-30 06:05:03 +00:00
// 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