lenses
lenses copied to clipboard
Filepath lenses
I was oggling r-lib/fs today and my goodness would filesystem lenses be amazing.
ext_l <- lens(view = fs::path_ext, set = fs::path_ext_set)
dirn_l <- lens(view = dirname, set = function(d, x){
mapply(function(dir, rpl, pth) sub(dir, rpl, pth, fixed = TRUE)
, dirname(d), x, d, SIMPLIFY = FALSE)
})
with
- [ ] basename
- [ ] path_rel/path_abs
- [ ] path2list/list2path
left as an exercise for the reader