Skip to content

Commit 2a73ab0

Browse files
committed
cleanup
1 parent 9995c3d commit 2a73ab0

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/api.js

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -214,75 +214,75 @@ class DICOMwebClient {
214214
* @param {String} url
215215
* @param {String} method
216216
* @param {Object} headers
217-
* @param {Request} [request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
217+
* @param {Request} [request] - Request Options
218218
* @param {Array} [request.data] - Data that should be stored
219219
* @return {*}
220220
* @private
221221
*/
222222
_httpRequest(url, method, headers = {}, request = {}) {
223223
const { errorInterceptor, requestHooks } = this;
224224
return new Promise((resolve, reject) => {
225-
let instance = request.instance ? request.instance : new XMLHttpRequest();
225+
let requestInstance = request.instance ? request.instance : new XMLHttpRequest();
226226

227-
instance.open(method, url, true);
227+
requestInstance.open(method, url, true);
228228
if ('responseType' in request) {
229-
instance.responseType = request.responseType;
229+
requestInstance.responseType = request.responseType;
230230
}
231231

232232
if (typeof headers === 'object') {
233233
Object.keys(headers).forEach(key => {
234-
instance.setRequestHeader(key, headers[key]);
234+
requestInstance.setRequestHeader(key, headers[key]);
235235
});
236236
}
237237

238238
// now add custom headers from the user
239239
// (e.g. access tokens)
240240
const userHeaders = this.headers;
241241
Object.keys(userHeaders).forEach(key => {
242-
instance.setRequestHeader(key, userHeaders[key]);
242+
requestInstance.setRequestHeader(key, userHeaders[key]);
243243
});
244244

245245
// Event triggered when upload starts
246-
instance.onloadstart = function onloadstart() {
246+
requestInstance.onloadstart = function onloadstart() {
247247
debugLog('upload started: ', url)
248248
};
249249

250250
// Event triggered when upload ends
251-
instance.onloadend = function onloadend() {
251+
requestInstance.onloadend = function onloadend() {
252252
debugLog('upload finished')
253253
};
254254

255255
// Handle response message
256-
instance.onreadystatechange = () => {
257-
if (instance.readyState === 4) {
258-
if (instance.status === 200) {
259-
const contentType = instance.getResponseHeader('Content-Type');
256+
requestInstance.onreadystatechange = () => {
257+
if (requestInstance.readyState === 4) {
258+
if (requestInstance.status === 200) {
259+
const contentType = requestInstance.getResponseHeader('Content-Type');
260260
// Automatically distinguishes between multipart and singlepart in an array buffer, and
261261
// converts them into a consistent type.
262262
if (contentType && contentType.indexOf('multipart') !== -1) {
263-
resolve(multipartDecode(instance.response));
264-
} else if (instance.responseType === 'arraybuffer') {
265-
resolve([instance.response]);
263+
resolve(multipartDecode(requestInstance.response));
264+
} else if (requestInstance.responseType === 'arraybuffer') {
265+
resolve([requestInstance.response]);
266266
} else {
267-
resolve(instance.response);
267+
resolve(requestInstance.response);
268268
}
269-
} else if (instance.status === 202) {
269+
} else if (requestInstance.status === 202) {
270270
if (this.verbose) {
271-
console.warn('some resources already existed: ', instance);
271+
console.warn('some resources already existed: ', requestInstance);
272272
}
273-
resolve(instance.response);
274-
} else if (instance.status === 204) {
273+
resolve(requestInstance.response);
274+
} else if (requestInstance.status === 204) {
275275
if (this.verbose) {
276-
console.warn('empty response for request: ', instance);
276+
console.warn('empty response for request: ', requestInstance);
277277
}
278278
resolve([]);
279279
} else {
280280
const error = new Error('request failed');
281-
error.request = instance;
282-
error.response = instance.response;
283-
error.status = instance.status;
281+
error.request = requestInstance;
282+
error.response = requestInstance.response;
283+
error.status = requestInstance.status;
284284
if (this.verbose) {
285-
console.error('request failed: ', instance);
285+
console.error('request failed: ', requestInstance);
286286
console.error(error);
287287
console.error(error.response);
288288
}
@@ -297,7 +297,7 @@ class DICOMwebClient {
297297
// Event triggered while download progresses
298298
if ('progressCallback' in request) {
299299
if (typeof request.progressCallback === 'function') {
300-
instance.onprogress = request.progressCallback;
300+
requestInstance.onprogress = request.progressCallback;
301301
}
302302
}
303303

@@ -307,20 +307,20 @@ class DICOMwebClient {
307307
const pipeRequestHooks = functions => args =>
308308
functions.reduce((props, fn) => fn(props, metadata), args);
309309
const pipedRequest = pipeRequestHooks(requestHooks);
310-
instance = pipedRequest(instance);
310+
requestInstance = pipedRequest(requestInstance);
311311
}
312312

313313
// Add withCredentials to request if needed
314314
if ('withCredentials' in request) {
315315
if (request.withCredentials) {
316-
instance.withCredentials = true;
316+
requestInstance.withCredentials = true;
317317
}
318318
}
319319

320320
if ('data' in request) {
321-
instance.send(request.data);
321+
requestInstance.send(request.data);
322322
} else {
323-
instance.send();
323+
requestInstance.send();
324324
}
325325
});
326326
}
@@ -789,7 +789,7 @@ class DICOMwebClient {
789789
* @param {String} url - Unique resource locator
790790
* @param {Object} headers - HTTP header fields
791791
* @param {Array} data - Data that should be stored
792-
* @param {Request} request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
792+
* @param {Request} request - Request Options
793793
* @private
794794
* @returns {Promise} Response
795795
*/
@@ -1371,7 +1371,7 @@ class DICOMwebClient {
13711371
* @param {String} options.sopInstanceUID - SOP Instance UID
13721372
* @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
13731373
* @param {Object} [options.queryParams] - HTTP query parameters
1374-
* @param {Request} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1374+
* @param {Request} [options.request] - Request Options
13751375
* @returns {Promise<ArrayBuffer>} Rendered DICOM Instance
13761376
*/
13771377
retrieveInstanceRendered(options) {
@@ -1456,7 +1456,7 @@ class DICOMwebClient {
14561456
* @param {String} options.sopInstanceUID - SOP Instance UID
14571457
* @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
14581458
* @param {Object} [options.queryParams] - HTTP query parameters
1459-
* @param {Request} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1459+
* @param {Request} [options.request] - Request Options
14601460
* @returns {ArrayBuffer} Thumbnail
14611461
*/
14621462
retrieveInstanceThumbnail(options) {
@@ -1520,7 +1520,7 @@ class DICOMwebClient {
15201520
* @param {String} options.frameNumbers - One-based indices of Frame Items
15211521
* @param {MediaType[]} [options.mediaTypes] - Acceptable HTTP media types
15221522
* @param {Object} [options.queryParams] - HTTP query parameters
1523-
* @param {Request} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1523+
* @param {Request} [options.request] - Request Options
15241524
* @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
15251525
*/
15261526
retrieveInstanceFramesRendered(options) {
@@ -1600,7 +1600,7 @@ class DICOMwebClient {
16001600
* @param {String} options.sopInstanceUID - SOP Instance UID
16011601
* @param {String} options.frameNumbers - One-based indices of Frame Items
16021602
* @param {Object} [options.queryParams] - HTTP query parameters
1603-
* @param {Request} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1603+
* @param {Request} [options.request] - Request Options
16041604
* @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays
16051605
*/
16061606
retrieveInstanceFramesThumbnail(options) {
@@ -1675,7 +1675,7 @@ class DICOMwebClient {
16751675
* @param {String} options.seriesInstanceUID - Series Instance UID
16761676
* @param {String} options.sopInstanceUID - SOP Instance UID
16771677
* @param {string[]} options.mediaTypes
1678-
* @param {Request} options.request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1678+
* @param {Request} options.request - Request Options
16791679
* @returns {Promise<ArrayBuffer>} DICOM Part 10 file as Arraybuffer
16801680
*/
16811681
retrieveInstance(options) {
@@ -1817,7 +1817,7 @@ class DICOMwebClient {
18171817
* @param {string} options.BulkDataURI to retrieve
18181818
* @param {Array} options.mediaTypes to use to fetch the URI
18191819
* @param {string} options.byteRange to request a sub-range (only valid on single part)
1820-
* @param {Request} options.request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects
1820+
* @param {Request} options.request - Request Options
18211821
* @returns {Promise<Array>} Bulkdata parts
18221822
*/
18231823
retrieveBulkData(options) {

0 commit comments

Comments
 (0)