diff --git a/packages/astro/components/Shiki.js b/packages/astro/components/Shiki.js index 9e8e60bc2..2d0644653 100644 --- a/packages/astro/components/Shiki.js +++ b/packages/astro/components/Shiki.js @@ -4,19 +4,21 @@ import { getHighlighter as getShikiHighlighter } from 'shiki'; const _resolvedHighlighters = new Map(); function stringify(opts) { - // Always sort keys before stringifying to make sure objects match regardless of parameter ordering - return JSON.stringify(opts, Object.keys(opts).sort()); + // Always sort keys before stringifying to make sure objects match regardless of parameter ordering + return JSON.stringify(opts, Object.keys(opts).sort()); } export function getHighlighter(opts) { - const key = stringify(opts); + const key = stringify(opts); - // Highlighter has already been requested, reuse the same instance - if (_resolvedHighlighters.has(key)) { return _resolvedHighlighters.get(key) } + // Highlighter has already been requested, reuse the same instance + if (_resolvedHighlighters.has(key)) { + return _resolvedHighlighters.get(key); + } - // Start the async getHighlighter call and cache the Promise - const highlighter = getShikiHighlighter(opts); - _resolvedHighlighters.set(key, highlighter); + // Start the async getHighlighter call and cache the Promise + const highlighter = getShikiHighlighter(opts); + _resolvedHighlighters.set(key, highlighter); - return highlighter; -} \ No newline at end of file + return highlighter; +}