From 5e3a9fbad6ba99864d3682f590164e217df65147 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 26 Jan 2022 03:32:41 -0500 Subject: [PATCH] Combines filter & map --- src/system/trie.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/system/trie.ts b/src/system/trie.ts index 300ca8b..2406176 100644 --- a/src/system/trie.ts +++ b/src/system/trie.ts @@ -1,6 +1,7 @@ import { Uri } from 'vscode'; import { isLinux } from '@env/platform'; import { DocumentSchemes } from '../constants'; +import { filterMap } from './iterable'; import { normalizePath as _normalizePath } from './path'; // TODO@eamodio don't import from string here since it will break the tests because of ESM dependencies // import { CharCode } from './string'; @@ -269,9 +270,12 @@ export class PathEntryTrie { } if (node?.children == null) return []; - return [...node.children.values()] - .filter(n => n.value) - .map(n => ({ value: n.value!, path: n.path, fullPath: fullPath })); + return [ + ...filterMap(node.children.values(), n => + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions + n.value ? { value: n.value, path: n.path, fullPath: fullPath } : undefined, + ), + ]; } getClosest( @@ -504,7 +508,8 @@ export class PathTrie { } if (node?.children == null) return []; - return [...node.children.values()].filter(n => n.value).map(n => n.value!); + // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions + return [...filterMap(node.children.values(), n => n.value || undefined)]; } getClosest(