Skip to content

Commit a8f68c0

Browse files
author
forrest
committed
refactor: handle eslint default-param-last cases
In all cases, this shouldn't affect the overall API. The changes are functionally the same, since default parameters only kick in if those parameters are given "undefined" as their argument.
1 parent c6d33b9 commit a8f68c0

File tree

5 files changed

+38
-44
lines changed

5 files changed

+38
-44
lines changed

Sources/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function removeLeadingSlash(str) {
2323
return str[0] === '/' ? str.substr(1) : str;
2424
}
2525

26-
function fetchText(instance = {}, url, options = {}) {
26+
function fetchText(instance, url, options = {}) {
2727
return new Promise((resolve, reject) => {
2828
const txt = getContent(url);
2929
if (txt === null) {
@@ -34,7 +34,7 @@ function fetchText(instance = {}, url, options = {}) {
3434
});
3535
}
3636

37-
function fetchJSON(instance = {}, url, options = {}) {
37+
function fetchJSON(instance, url, options = {}) {
3838
return new Promise((resolve, reject) => {
3939
const txt = getContent(removeLeadingSlash(url));
4040
if (txt === null) {
@@ -45,7 +45,7 @@ function fetchJSON(instance = {}, url, options = {}) {
4545
});
4646
}
4747

48-
function fetchArray(instance = {}, baseURL, array, options = {}) {
48+
function fetchArray(instance, baseURL, array, options = {}) {
4949
return new Promise((resolve, reject) => {
5050
const url = removeLeadingSlash(
5151
[
@@ -105,10 +105,10 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
105105

106106
// Done with the ref and work
107107
delete array.ref;
108-
if (--requestCount === 0 && instance.invokeBusy) {
108+
if (--requestCount === 0 && instance?.invokeBusy) {
109109
instance.invokeBusy(false);
110110
}
111-
if (instance.modified) {
111+
if (instance?.modified) {
112112
instance.modified();
113113
}
114114

@@ -119,7 +119,7 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
119119

120120
// ----------------------------------------------------------------------------
121121

122-
function fetchImage(instance = {}, url, options = {}) {
122+
function fetchImage(instance, url, options = {}) {
123123
return new Promise((resolve, reject) => {
124124
const img = getElement(url);
125125
if (img) {

Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function fetchBinary(url, options = {}) {
6060
});
6161
}
6262

63-
function fetchArray(instance = {}, baseURL, array, options = {}) {
63+
function fetchArray(instance, baseURL, array, options = {}) {
6464
if (array.ref && !array.ref.pending) {
6565
return new Promise((resolve, reject) => {
6666
const url = [
@@ -73,7 +73,7 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
7373
xhr.onreadystatechange = (e) => {
7474
if (xhr.readyState === 1) {
7575
array.ref.pending = true;
76-
if (++requestCount === 1 && instance.invokeBusy) {
76+
if (++requestCount === 1 && instance?.invokeBusy) {
7777
instance.invokeBusy(true);
7878
}
7979
}
@@ -117,10 +117,10 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
117117

118118
// Done with the ref and work
119119
delete array.ref;
120-
if (--requestCount === 0 && instance.invokeBusy) {
120+
if (--requestCount === 0 && instance?.invokeBusy) {
121121
instance.invokeBusy(false);
122122
}
123-
if (instance.modified) {
123+
if (instance?.modified) {
124124
instance.modified();
125125
}
126126
resolve(array);
@@ -144,18 +144,18 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
144144

145145
// ----------------------------------------------------------------------------
146146

147-
function fetchJSON(instance = {}, url, options = {}) {
147+
function fetchJSON(instance, url, options = {}) {
148148
return new Promise((resolve, reject) => {
149149
const xhr = openAsyncXHR('GET', url, options);
150150

151151
xhr.onreadystatechange = (e) => {
152152
if (xhr.readyState === 1) {
153-
if (++requestCount === 1 && instance.invokeBusy) {
153+
if (++requestCount === 1 && instance?.invokeBusy) {
154154
instance.invokeBusy(true);
155155
}
156156
}
157157
if (xhr.readyState === 4) {
158-
if (--requestCount === 0 && instance.invokeBusy) {
158+
if (--requestCount === 0 && instance?.invokeBusy) {
159159
instance.invokeBusy(false);
160160
}
161161
if (xhr.status === 200 || xhr.status === 0) {
@@ -182,7 +182,7 @@ function fetchJSON(instance = {}, url, options = {}) {
182182

183183
// ----------------------------------------------------------------------------
184184

185-
function fetchText(instance = {}, url, options = {}) {
185+
function fetchText(instance, url, options = {}) {
186186
if (options && options.compression && options.compression !== 'gz') {
187187
vtkErrorMacro('Supported algorithms are: [gz]');
188188
vtkErrorMacro(`Unkown compression algorithm: ${options.compression}`);
@@ -193,12 +193,12 @@ function fetchText(instance = {}, url, options = {}) {
193193

194194
xhr.onreadystatechange = (e) => {
195195
if (xhr.readyState === 1) {
196-
if (++requestCount === 1 && instance.invokeBusy) {
196+
if (++requestCount === 1 && instance?.invokeBusy) {
197197
instance.invokeBusy(true);
198198
}
199199
}
200200
if (xhr.readyState === 4) {
201-
if (--requestCount === 0 && instance.invokeBusy) {
201+
if (--requestCount === 0 && instance?.invokeBusy) {
202202
instance.invokeBusy(false);
203203
}
204204
if (xhr.status === 200 || xhr.status === 0) {
@@ -223,7 +223,7 @@ function fetchText(instance = {}, url, options = {}) {
223223

224224
// ----------------------------------------------------------------------------
225225

226-
function fetchImage(instance = {}, url, options = {}) {
226+
function fetchImage(instance, url, options = {}) {
227227
return new Promise((resolve, reject) => {
228228
const img = new Image();
229229
if (options.crossOrigin) {

Sources/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function create(createOptions) {
111111
}
112112
});
113113
return {
114-
fetchArray(instance = {}, baseURL, array, options = {}) {
114+
fetchArray(instance, baseURL, array, options = {}) {
115115
return new Promise((resolve, reject) => {
116116
if (!ready) {
117117
vtkErrorMacro('ERROR!!! zip not ready...');
@@ -124,17 +124,17 @@ function create(createOptions) {
124124
].join('/')
125125
);
126126

127-
if (++requestCount === 1 && instance.invokeBusy) {
127+
if (++requestCount === 1 && instance?.invokeBusy) {
128128
instance.invokeBusy(true);
129129
}
130130

131131
function doneCleanUp() {
132132
// Done with the ref and work
133133
delete array.ref;
134-
if (--requestCount === 0 && instance.invokeBusy) {
134+
if (--requestCount === 0 && instance?.invokeBusy) {
135135
instance.invokeBusy(false);
136136
}
137-
if (instance.modified) {
137+
if (instance?.modified) {
138138
instance.modified();
139139
}
140140
resolve(array);
@@ -153,7 +153,7 @@ function create(createOptions) {
153153
});
154154
},
155155

156-
fetchJSON(instance = {}, url, options = {}) {
156+
fetchJSON(instance, url, options = {}) {
157157
const path = cleanUpPath(url);
158158
if (!ready) {
159159
vtkErrorMacro('ERROR!!! zip not ready...');
@@ -177,7 +177,7 @@ function create(createOptions) {
177177
.then((str) => Promise.resolve(JSON.parse(str)));
178178
},
179179

180-
fetchText(instance = {}, url, options = {}) {
180+
fetchText(instance, url, options = {}) {
181181
const path = cleanUpPath(url);
182182
if (!ready) {
183183
vtkErrorMacro('ERROR!!! zip not ready...');
@@ -202,7 +202,7 @@ function create(createOptions) {
202202
.then((str) => Promise.resolve(str));
203203
},
204204

205-
fetchImage(instance = {}, url, options = {}) {
205+
fetchImage(instance, url, options = {}) {
206206
const path = cleanUpPath(url);
207207
if (!ready) {
208208
vtkErrorMacro('ERROR!!! zip not ready...');
@@ -222,7 +222,7 @@ function create(createOptions) {
222222
});
223223
},
224224

225-
fetchBinary(instance = {}, url, options = {}) {
225+
fetchBinary(instance, url, options = {}) {
226226
const path = cleanUpPath(url);
227227
if (!ready) {
228228
vtkErrorMacro('ERROR!!! zip not ready...');

Sources/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function fetchBinary(url, options = {}) {
5656
});
5757
}
5858

59-
function fetchArray(instance = {}, baseURL, array, options = {}) {
59+
function fetchArray(instance, baseURL, array, options = {}) {
6060
if (options && options.compression) {
6161
return REJECT_COMPRESSION();
6262
}
@@ -69,7 +69,7 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
6969
xhr.onreadystatechange = (e) => {
7070
if (xhr.readyState === 1) {
7171
array.ref.pending = true;
72-
if (++requestCount === 1 && instance.invokeBusy) {
72+
if (++requestCount === 1 && instance?.invokeBusy) {
7373
instance.invokeBusy(true);
7474
}
7575
}
@@ -101,10 +101,10 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
101101

102102
// Done with the ref and work
103103
delete array.ref;
104-
if (--requestCount === 0 && instance.invokeBusy) {
104+
if (--requestCount === 0 && instance?.invokeBusy) {
105105
instance.invokeBusy(false);
106106
}
107-
if (instance.modified) {
107+
if (instance?.modified) {
108108
instance.modified();
109109
}
110110
resolve(array);
@@ -125,7 +125,7 @@ function fetchArray(instance = {}, baseURL, array, options = {}) {
125125

126126
// ----------------------------------------------------------------------------
127127

128-
function fetchJSON(instance = {}, url, options = {}) {
128+
function fetchJSON(instance, url, options = {}) {
129129
if (options && options.compression) {
130130
return REJECT_COMPRESSION();
131131
}
@@ -135,12 +135,12 @@ function fetchJSON(instance = {}, url, options = {}) {
135135

136136
xhr.onreadystatechange = (e) => {
137137
if (xhr.readyState === 1) {
138-
if (++requestCount === 1 && instance.invokeBusy) {
138+
if (++requestCount === 1 && instance?.invokeBusy) {
139139
instance.invokeBusy(true);
140140
}
141141
}
142142
if (xhr.readyState === 4) {
143-
if (--requestCount === 0 && instance.invokeBusy) {
143+
if (--requestCount === 0 && instance?.invokeBusy) {
144144
instance.invokeBusy(false);
145145
}
146146
if (xhr.status === 200 || xhr.status === 0) {
@@ -159,7 +159,7 @@ function fetchJSON(instance = {}, url, options = {}) {
159159

160160
// ----------------------------------------------------------------------------
161161

162-
function fetchText(instance = {}, url, options = {}) {
162+
function fetchText(instance, url, options = {}) {
163163
if (options && options.compression) {
164164
return REJECT_COMPRESSION();
165165
}
@@ -169,12 +169,12 @@ function fetchText(instance = {}, url, options = {}) {
169169

170170
xhr.onreadystatechange = (e) => {
171171
if (xhr.readyState === 1) {
172-
if (++requestCount === 1 && instance.invokeBusy) {
172+
if (++requestCount === 1 && instance?.invokeBusy) {
173173
instance.invokeBusy(true);
174174
}
175175
}
176176
if (xhr.readyState === 4) {
177-
if (--requestCount === 0 && instance.invokeBusy) {
177+
if (--requestCount === 0 && instance?.invokeBusy) {
178178
instance.invokeBusy(false);
179179
}
180180
if (xhr.status === 200 || xhr.status === 0) {
@@ -193,7 +193,7 @@ function fetchText(instance = {}, url, options = {}) {
193193

194194
// ----------------------------------------------------------------------------
195195

196-
function fetchImage(instance = {}, url, options = {}) {
196+
function fetchImage(instance, url, options = {}) {
197197
return new Promise((resolve, reject) => {
198198
const img = new Image();
199199
if (options.crossOrigin) {

Sources/IO/Core/ImageStream/DefaultProtocol.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,9 @@ export default function createMethods(session) {
3131
session.call('viewport.image.animation.start', [viewId]),
3232
stopAnimation: (viewId = -1) =>
3333
session.call('viewport.image.animation.stop', [viewId]),
34-
updateCamera: (
35-
viewId = -1,
36-
focalPoint,
37-
viewUp,
38-
position,
39-
forceUpdate = true
40-
) =>
34+
updateCamera: (viewId, focalPoint, viewUp, position, forceUpdate = true) =>
4135
session.call('viewport.camera.update', [
42-
viewId,
36+
viewId ?? -1,
4337
focalPoint,
4438
viewUp,
4539
position,

0 commit comments

Comments
 (0)