Files
dotfiles/dot_config/nushell/nu_scripts/stdlib-candidate/std-rfc/flatter.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

12 lines
294 B
Nu

# A command to flatten many levels by using recursion
# by @jturner 2/10/21
# Example: sys | flatter 3
def flatter [levels:int] {
let input = $in
if $levels > 0 {
$input | columns | reduce -f $input {|it acc| $acc | flatten $it } | flatter ($levels - 1)
} else {
$input
}
}