UNPKG

@markuplint/ml-spec

Version:

Types and schema that specs of the Markup languages for markuplint

13 lines (12 loc) 467 B
import { resolveNamespace } from '../utils/resolve-namespace.js'; const cache = new Map(); export function getSpecByTagName(specs, localName, namespace) { const { localNameWithNS } = resolveNamespace(localName, namespace ?? undefined); let spec = cache.get(localNameWithNS); if (spec !== undefined) { return spec; } spec = specs.find(spec => spec.name === localNameWithNS) ?? null; cache.set(localNameWithNS, spec); return spec; }