-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch: use single generator instance, remove render bottleneck
- Loading branch information
1 parent
c1f997f
commit 98eebd7
Showing
2 changed files
with
22 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,13 +35,16 @@ export { default as presetWind } from "https://cdn.skypack.dev/@unocss/preset-wi | |
export { default as presetTypography } from "https://cdn.skypack.dev/@unocss/[email protected]"; | ||
export { default as presetIcons } from "https://cdn.skypack.dev/@unocss/[email protected]"; | ||
|
||
const _iconifyCache = new Map(); | ||
export const iconifyCollections = async (...sets: string[]) => { | ||
const reqs = [], sourceUrl = "https://esm.sh/@iconify/[email protected]/json"; | ||
for (const set of sets) { | ||
reqs.push( | ||
fetch(`${sourceUrl}/${set}.json`) | ||
.then((res) => res.json()).then((json) => [set, json]), | ||
); | ||
if (!_iconifyCache.has(set)) { | ||
const req = fetch(`${sourceUrl}/${set}.json`) | ||
.then((res) => res.json()).then((json) => [set, json]); | ||
_iconifyCache.set(set, req); | ||
} | ||
reqs.push(_iconifyCache.get(set)); | ||
} | ||
return { collections: Object.fromEntries(await Promise.all(reqs)) }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters