flatten

This block is part of the array group and was last modified in core v10.6.1.

flatten v10.6.1

Accepts a nested array and returns a flattened array.

In pins 2
  • array required
    array

    Input pin for the nested array to be flattened.

  • max depth required
    number

    Optional input pin to specify the maximum depth for flattening (optional). • Hidden when unused

Out pins 1
  • Array
    array

    Output pin for the flattened array.

Recursively flattens nested arrays into one flat array. A maxdepth greater than 0 flattens only that many levels, keeping deeper arrays intact as elements; 0 or unset flattens completely. Non-array input outputs null. Example: [[1,[2]],3] -> [1,2,3] fully, or [1,[2],3] with maxdepth 1.

nested

A typical wiring for flatten: select field values feeds the array pin; number feeds the maxdepth pin; the array out pin feeds remove duplicates.

Studio canvas example for the flatten block: typical wiring for flatten.

Commonly used with

In production blueprints, this block is most often wired together with:

  • select field values: feeds into this block. returns an array with values of the given field in this array of objects.
  • remove duplicates: this block feeds into it. Removes duplicate values from an array.
  • array includes: this block feeds into it. determines whether an array includes a certain value among its entries.
  • exclude by value: this block feeds into it. Removes the items equal to the given value. Returns all items that do NOT match.
  • find by key - value: this block feeds into it. Returns the matching objects for the given key value pair.
  • map: this block feeds into it. Creates a new array with the results of the provided function on every element in the array.

Version history

Introduced in v10.6.1.


Back to array Return to the main group to view all sub-groups Back to array Return to the group to view all blocks within this group