@@ -153,7 +153,7 @@ export class DataProcessor {
153
153
private _fetcher : Fetcher | undefined ;
154
154
private readonly requestInitGenerator : RequestInitGenerator ;
155
155
private readonly mapping : { [ k : string ] : ResponseTransformer [ ] } ;
156
- private readonly requestMap : { [ k : string ] : Promise < Statement [ ] > | undefined } ;
156
+ private readonly requestMap : Map < NamedNode , Promise < Statement [ ] > | undefined > ;
157
157
private readonly requestNotifier ?: RequestCallbackHandler ;
158
158
private readonly store : RDFStore ;
159
159
@@ -182,7 +182,7 @@ export class DataProcessor {
182
182
} ;
183
183
this . requestInitGenerator = opts . requestInitGenerator || new RequestInitGenerator ( ) ;
184
184
this . mapping = opts . mapping || { } ;
185
- this . requestMap = { } ;
185
+ this . requestMap = new Map ( ) ;
186
186
this . store = opts . store ;
187
187
this . requestNotifier = opts . requestNotifier ;
188
188
if ( opts . fetcher ) {
@@ -290,14 +290,16 @@ export class DataProcessor {
290
290
const url = new URL ( iri . value ) ;
291
291
url . hash = "" ;
292
292
const requestIRI = new NamedNode ( url . toString ( ) ) ;
293
- if ( typeof this . requestMap [ requestIRI . toString ( ) ] !== "undefined" ) {
294
- return this . requestMap [ requestIRI . toString ( ) ] || [ ] ;
293
+ if ( this . requestMap . has ( requestIRI ) ) {
294
+ return this . requestMap . get ( requestIRI ) || [ ] ;
295
295
}
296
296
297
297
try {
298
- return this . requestMap [ requestIRI . toString ( ) ] = this
298
+ const req = this
299
299
. fetchResource ( requestIRI , opts )
300
300
. then ( ( res ) => this . feedResponse ( res ) ) ; // TODO: feedResponse is only necessary for external requests.
301
+ this . requestMap . set ( requestIRI , req ) ;
302
+ return await req ;
301
303
} catch ( e ) {
302
304
if ( typeof e . res === "undefined" ) {
303
305
throw e ;
@@ -307,7 +309,7 @@ export class DataProcessor {
307
309
308
310
return responseQuads ;
309
311
} finally {
310
- this . requestMap [ requestIRI . toString ( ) ] = undefined ;
312
+ this . requestMap . delete ( requestIRI ) ;
311
313
}
312
314
}
313
315
0 commit comments