[ci] format

This commit is contained in:
tony-sull 2022-04-18 16:31:07 +00:00 committed by github-actions[bot]
parent 394ab90547
commit dfa1042f2b

View file

@ -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;
}
return highlighter;
}