From 1b33aa2bc188d309b3588f51df74e0bb777d6128 Mon Sep 17 00:00:00 2001 From: ErikPham Date: Mon, 10 Jun 2024 13:58:52 +0700 Subject: [PATCH] fix: initial for multiple result --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2facd9f..4792e18 100644 --- a/src/index.ts +++ b/src/index.ts @@ -207,7 +207,7 @@ export function createGoogleFontsFetch(defaultOptions: GoogleFontsFetchOptions): extend(fontOptions, { css: { write: false, merge: false } }) } - let multipleResult: FetchFontsResult + let multipleResult: FetchFontsResult = [] try { multipleResult = await context.multiple(multiple, fontOptions) } @@ -217,10 +217,14 @@ export function createGoogleFontsFetch(defaultOptions: GoogleFontsFetchOptions): } catch (e) { errors.push(...chunkFamilies[i]) + multipleResult = [] } } - success.push(...multipleResult) + if (multipleResult.length > 0) { + success.push(...multipleResult) + } + if (baseOptions.chunk.delay) { await delay(baseOptions.chunk.delay) }