From 54bbd9ead79fa3c5529d02b4436d696f96810849 Mon Sep 17 00:00:00 2001 From: defx Date: Wed, 9 Dec 2020 00:24:04 +0000 Subject: [PATCH] tidy --- src/pathMap.js | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/pathMap.js diff --git a/src/pathMap.js b/src/pathMap.js deleted file mode 100644 index 4c5dfec..0000000 --- a/src/pathMap.js +++ /dev/null @@ -1,26 +0,0 @@ -export default () => { - let valueToPaths = new WeakMap(); - let pathToId = new Map(); - let id = 0; - - return { - appendAll(value, paths) { - if (!valueToPaths.has(value)) valueToPaths.set(value, new Map()); - const map = valueToPaths.get(value); - for (let path of paths) { - map.set(path, ++id); - pathToId.set(path, id); - } - valueToPaths.set(value, map); - }, - get(value) { - if (!valueToPaths.has(value)) return []; - - const entries = Array.from(valueToPaths.get(value)).filter( - ([path, id]) => pathToId.get(path) === id - ); - valueToPaths.set(value, new Map(entries)); - return entries.map(([path, id]) => path); - }, - }; -};