FEATURE: Add a module for stripping NULL fields from a tuple.

This commit is contained in:
Jeremy Wall 2019-01-15 19:31:55 -06:00
parent e838554fff
commit b9b30a4bd1
2 changed files with 15 additions and 0 deletions

View File

@ -14,4 +14,9 @@ assert t.equal{
assert t.equal{ assert t.equal{
left = tpl.iter{tpl={foo=1, bar=2}}.result, left = tpl.iter{tpl={foo=1, bar=2}}.result,
right = [["foo", 1], ["bar", 2]], right = [["foo", 1], ["bar", 2]],
};
assert t.equal{
left = tpl.strip_nulls{tpl={foo="bar", bar=NULL}}.result,
right = {foo="bar"},
}; };

View File

@ -29,4 +29,14 @@ let iter = module{
}; };
let result = reduce reducer.result [], (mod.tpl); let result = reduce reducer.result [], (mod.tpl);
};
let strip_nulls = module{
tpl = NULL,
} => {
let filterer = macro(name, value) => {
result = value != NULL,
};
let result = filter filterer.result (mod.tpl);
}; };