Tree.

deflatePaths(map, [options])

Given a map-based tree, this returns a flattened Map of slash-separated paths to values.

The options argument can include:

  • assumeSlashKeys: if true, the operation will skip descending into a value if the tree supports trailing slashes and the key does not end in a trailing slash. This speeds up the operation on large trees.
  • base: a string that will be prepended to all the paths.

Example #

A folder contains a set of markdown posts organized into subfolders for year and month:

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

This can be flattened with:

$ ori Tree.deflatePaths posts
2027/07/04.md: First post
2027/07/07.md: Second post
2027/08/01.md: Third post
2027/08/04.md: Fourth post

See also the inverse operation, Tree.inflatePaths. The related Tree.paths returns just the paths as an array.