indigo0086

Filter child fields simple

Jun 16th, 2021
1,008
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var paths = ['a', 'a/b', 'test/a', 'c', 'test', 'a/b/c']
  2. var filtered = paths.filter(p1 => {
  3.   const isChildPath = paths.some(p2 => p1.includes(`${p2}/`))
  4.   return !isChildPath;
  5. })
  6. console.log(filtered)
RAW Paste Data