@@ -21,10 +21,10 @@ import { getheaderToken } from "./headerUtils";
2121 * @property {string[] } contentTypes - Array of strings of content types that the parser should parse for ESI Tags
2222 * Note: That these are case sensitive. See - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
2323 * @property {boolean } disableThirdPartyIncludes - Whether or not to enable third party includes (includes from other domains)
24- * @property {number } [recursionLimit] - Levels of recusion the parser is allowed to go do
25- * think includes that include themselves causing recusion
24+ * @property {number } [recursionLimit] - Levels of recursion the parser is allowed to include before bailing out
25+ * think includes that include themselves causing recursion
2626 * @default 10
27- * @property {string[] } thirdPatyIncludesDomainWhitelist - If third party includes are disabled you can white list them by including domains here
27+ * @property {string[] } thirdPartyIncludesDomainWhitelist - If third party includes are disabled you can white list them by including domains here
2828 * @property {string[] } varsCookieBlacklist - Array of strings of cookies that will be blacklisted from being expanded in esi VARs.
2929 */
3030export type ESIConfig = {
@@ -47,14 +47,14 @@ export type ESIVars = {
4747 * ESI Event Data for the Current Request
4848 *
4949 * @property {ESIConfig } config - ESIConfig when class was created
50- * @property {object } headers - All headers of the request uppercased
50+ * @property {object } headers - All headers of the request in uppercase
5151 * @property {string } method - Method of the request
5252 * @property {URLSearchParams } esiArgs - Any ESI Arguments extracted from the URL Search params of the original request
5353 * Will be a URLSearchParam encoded object
5454 * @property {customESIVars } customVars - If a custom ESI Vars function is supplied this will be the result of that function
5555 * @property {URL } url - URL Object of the Request with ESI Args removed
5656 * @property {Request } request - Request object after ESI Args have been removed
57- * @property {number } recursion - Recusion level we're currently at
57+ * @property {number } recursion - Recursion level we're currently at
5858 */
5959export type ESIEventData = {
6060 /**
@@ -63,7 +63,7 @@ export type ESIEventData = {
6363 config : ESIConfig ;
6464 /**
6565 * All headers of the current Request in {Object}
66- * All headers are uppercassed with - being converted to _
66+ * All headers are in uppercase and - is converted to _
6767 */
6868 headers : { [ key : string ] : string } ;
6969 /**
@@ -101,7 +101,7 @@ export type customESIVars = {
101101} ;
102102export type customESIVarsFunction = (
103103 request : Request ,
104- ) => Promise < customESIVars > ;
104+ ) => Promise < customESIVars > | customESIVars ;
105105export type fetchFunction = (
106106 request : RequestInfo ,
107107 ctx : Request [ ] ,
@@ -150,7 +150,7 @@ export class esi {
150150 // Remove ESI Vars if they're in the request
151151 // Return a brand new request
152152 // eslint-disable-next-line
153- let [ request , esiVars ] = await getVars ( origRequest ) ;
153+ let [ request , esiVars ] = getVars ( origRequest ) ;
154154
155155 // Load custom values if we can
156156 let customESIVariables ;
@@ -159,7 +159,7 @@ export class esi {
159159 }
160160
161161 // Add SurrogateControl header or append to it
162- request = await advertiseSurrogateControl ( request ) ;
162+ request = advertiseSurrogateControl ( request ) ;
163163
164164 // pack our nice stuff in
165165 const eventData : ESIEventData = {
@@ -189,7 +189,7 @@ export class esi {
189189 ! response . body ||
190190 ! this . validContentType ( response ) ||
191191 ! this . validSurrogateControl ( response ) ||
192- ( await canDelegateToSurrogate ( origRequest , this . options ) )
192+ canDelegateToSurrogate ( origRequest , this . options )
193193 ) {
194194 const resp = new Response ( response . body , response ) ;
195195 // We set the URL manually here as it doesn't come across from the copy˛
@@ -230,10 +230,10 @@ export class esi {
230230 }
231231
232232 async handleESI ( eventData : ESIEventData , text : string ) : Promise < string > {
233- text = await processEscaping ( text ) ;
233+ text = processEscaping ( text ) ;
234234 text = processComments ( text ) ;
235235 text = processRemove ( text ) ;
236- text = await processESIVars ( eventData , text ) ;
236+ text = processESIVars ( eventData , text ) ;
237237 let vars = false ;
238238 [ text , vars ] = await processConditionals ( eventData , text ) ;
239239
@@ -249,15 +249,16 @@ export class esi {
249249
250250 return text ;
251251 }
252+ // eslint-disable-next-line require-await
252253 async handleTEXT ( eventData : ESIEventData , text : string ) : Promise < string > {
253254 return text ;
254255 }
255256
256- async streamBody (
257+ streamBody (
257258 eventData : ESIEventData ,
258259 readable : ReadableStream ,
259260 writable : WritableStream ,
260- ) : Promise < void > {
261+ ) {
261262 const reader = readable . getReader ( ) ;
262263 const encoder = new TextEncoder ( ) ;
263264 const decoder = new TextDecoder ( ) ;
@@ -328,12 +329,12 @@ export class esi {
328329
329330 const handler = createHandleChunk ( writerBound ) ;
330331
331- reader . read ( ) . then ( async function processBlob ( blob ) : Promise < void > {
332+ reader . read ( ) . then ( function processBlob ( blob ) : Promise < void > | undefined {
332333 const chunk : ArrayBuffer = blob . value ;
333334 const done : boolean = blob . done ;
334335 // decode it
335336 const decodedChunk : string = decoder . decode ( chunk , { stream : true } ) ;
336- await handler ( decodedChunk , done ) ;
337+ handler ( decodedChunk , done ) ;
337338
338339 // we're done bail out
339340 if ( done ) {
@@ -390,9 +391,9 @@ const esiArgsRegex = /^esi_(\S+)/;
390391 * Return a brand new mutatable Request along with an ESIVars object
391392 *
392393 * @param {Request } request - Original Request
393- * @returns {Promise< [Request, ESIVars]> } - Mutatable Request and ESIVars
394+ * @returns {[Request, ESIVars] } - Mutatable Request and ESIVars
394395 */
395- async function getVars ( request : Request ) : Promise < [ Request , ESIVars ] > {
396+ function getVars ( request : Request ) : [ Request , ESIVars ] {
396397 const vars : ESIVars = {
397398 headers : { } ,
398399 method : request . method ,
@@ -466,7 +467,7 @@ export function getProcessorVersionString(): string {
466467 * @param {Request[] } ctx request ctx (parent requests)
467468 * @returns {Promise<Response> } - processor supported version
468469 */
469- async function defaultFetch (
470+ function defaultFetch (
470471 req : RequestInfo ,
471472 // eslint-disable-next-line @typescript-eslint/no-unused-vars
472473 ctx : Request [ ] ,
0 commit comments