diff options
author | 2022-04-18 16:31:07 +0000 | |
---|---|---|
committer | 2022-04-18 16:31:07 +0000 | |
commit | dfa1042f2bc5e620e4aa86f5a4c295010715e7f2 (patch) | |
tree | c94cf559b81c7efc438a46641d2356ffd6382e74 | |
parent | 394ab9054714586c1b5bb163f02fe17412527ebc (diff) | |
download | astro-dfa1042f2bc5e620e4aa86f5a4c295010715e7f2.tar.gz astro-dfa1042f2bc5e620e4aa86f5a4c295010715e7f2.tar.zst astro-dfa1042f2bc5e620e4aa86f5a4c295010715e7f2.zip |
[ci] format
-rw-r--r-- | packages/astro/components/Shiki.js | 22 |
1 files changed, 12 insertions, 10 deletions
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; +} |