@@ -30,7 +30,7 @@ const MEDIATYPES = {
3030 * A callback with the request instance and metadata information
3131 * of the currently request being executed that should necessarily
3232 * return the given request optionally modified.
33- * @typedef {function } RequestInterceptor
33+ * @typedef {function } RequestHook
3434 * @param {XMLHttpRequest } request - The original XMLHttpRequest instance.
3535 * @param {object } metadata - The metadata used by the request.
3636 */
@@ -46,7 +46,7 @@ class DICOMwebClient {
4646 * @param {String } options.username - Username
4747 * @param {String } options.password - Password
4848 * @param {Object } options.headers - HTTP headers
49- * @param {Array.<RequestInterceptor > } options.requestInterceptors - Request interceptors .
49+ * @param {Array.<RequestHook > } options.requestHooks - Request hooks .
5050 */
5151 constructor ( options ) {
5252 this . baseURL = options . url ;
@@ -85,8 +85,8 @@ class DICOMwebClient {
8585 this . stowURL = this . baseURL ;
8686 }
8787
88- if ( "requestInterceptors " in options ) {
89- this . requestInterceptors = options . requestInterceptors ;
88+ if ( "requestHooks " in options ) {
89+ this . requestHooks = options . requestHooks ;
9090 }
9191
9292 // Headers to pass to requests.
@@ -114,13 +114,13 @@ class DICOMwebClient {
114114 * @param {String } method
115115 * @param {Object } headers
116116 * @param {Object } options
117- * @param {Array.<RequestInterceptor > } options.requestInterceptors - Request interceptors .
117+ * @param {Array.<RequestHook > } options.requestHooks - Request hooks .
118118 * @return {* }
119119 * @private
120120 */
121121 _httpRequest ( url , method , headers , options = { } ) {
122122
123- const { errorInterceptor, requestInterceptors } = this ;
123+ const { errorInterceptor, requestHooks } = this ;
124124
125125 return new Promise ( ( resolve , reject ) => {
126126 let request = new XMLHttpRequest ( ) ;
@@ -186,11 +186,10 @@ class DICOMwebClient {
186186 }
187187 }
188188
189- if ( requestInterceptors ) {
190- console . debug ( 'yes' )
189+ if ( requestHooks ) {
191190 const metadata = { method, url } ;
192- const pipeRequestInterceptors = functions => ( args ) => functions . reduce ( ( args , fn ) => fn ( args , metadata ) , args ) ;
193- const pipedRequest = pipeRequestInterceptors ( requestInterceptors ) ;
191+ const pipeRequstHooks = functions => ( args ) => functions . reduce ( ( args , fn ) => fn ( args , metadata ) , args ) ;
192+ const pipedRequest = pipeRequstHooks ( requestHooks ) ;
194193 request = pipedRequest ( request ) ;
195194 }
196195
0 commit comments