Skip to content

divideBy

divideBy(object, n) → array · Object

Divide an object into sub-objects each containing at most N key-value pairs.

  • object (required): object to split

  • n (required): max entries per sub-object

bash
echo '{"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}' | utlx -e 'divideBy($input, 2)'
# [{"a": 1, "b": 2}, {"c": 3, "d": 4}, {"e": 5}]
utlx
{
  batches: divideBy($input.config, 3)
}

Released under AGPL-3.0.