Tree.

flat(map, [depth])

Flattens the values of the map-based tree to the indicated depth. If depth is omitted, a single level of the tree is flattened.

This can be useful when, for example, you have a folder or tree-like hierarchy in which individual items have unique names, and you want to flatten that hierarchy by a given amount.

Example: a folder called posts contains subfolders numbered by year, then by month:

$ ori posts
"2027":
  07-July:
    2027-07-04.md: First post
    2027-07-07.md: Second post
  08-August:
    2027-08-01.md: Third post
    2027-08-04.md: Fourth post

Passing this folder tree to Tree.flat flattens it by one level:

$ ori Tree.flat posts
07-July:
  2027-07-04.md: First post
  2027-07-07.md: Second post
08-August:
  2027-08-01.md: Third post
  2027-08-04.md: Fourth post

You can flatten the entire tree by passing a depth of Infinity:

$ ori Tree.flat posts, Infinity
2027-07-04.md: First post
2027-07-07.md: Second post
2027-08-01.md: Third post
2027-08-04.md: Fourth post

Note: if the flattened keys are all numeric, the result is an array with renumbered indices:

$ ori "Tree.flat([['a', 'b'], { 5: 'c', 6: 'd' }])"
- a
- b
- c
- d