diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-02-16 16:11:13 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-02-17 17:09:18 -0400 |
commit | b7debd668d03b2236cea1b0291acb8efc6f3ee0d (patch) | |
tree | 6a3825d7d489b9f9d41d1e579090c4994cd2395a /src/data | |
parent | 74ded573b9e24b120573a3f5319de7501b17a759 (diff) |
data-checks, sugar: factor out getNestedProp
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/checks.js | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/data/checks.js b/src/data/checks.js index ad86087b..96f4cd8c 100644 --- a/src/data/checks.js +++ b/src/data/checks.js @@ -4,7 +4,7 @@ import {inspect as nodeInspect} from 'node:util'; import {colors, ENABLE_COLOR} from '#cli'; import CacheableObject from '#cacheable-object'; -import {compareArrays, empty} from '#sugar'; +import {compareArrays, empty, getNestedProp} from '#sugar'; import Thing from '#thing'; import thingConstructors from '#things'; import {commentaryRegexCaseSensitive} from '#wiki-data'; @@ -167,13 +167,6 @@ export function filterReferenceErrors(wikiData, { }], ]; - function getNestedProp(obj, key) { - const recursive = (o, k) => - k.length === 1 ? o[k[0]] : recursive(o[k[0]], k.slice(1)); - const keys = key.split(/(?<=(?<!\\)(?:\\\\)*)\./); - return recursive(obj, keys); - } - const boundFind = bindFind(wikiData, {mode: 'error'}); const findArtistOrAlias = artistRef => { |