Skip to content

Commit f4507e6

Browse files
author
Arpit Malik
committed
fix: Removed linted lined
2 parents 4af39af + f3c88f2 commit f4507e6

File tree

1 file changed

+12
-41
lines changed

1 file changed

+12
-41
lines changed

src/EventSource.js

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ class EventSource {
5151
this._pollTimer = null;
5252
this._lastIndexProcessed = 0;
5353

54-
if (
55-
!url ||
56-
(typeof url !== 'string' && typeof url.toString !== 'function')
57-
) {
54+
if (!url || (typeof url !== 'string' && typeof url.toString !== 'function')) {
5855
throw new SyntaxError('[EventSource] Invalid URL argument.');
5956
}
6057

@@ -106,34 +103,23 @@ class EventSource {
106103

107104
const xhr = this._xhr;
108105

109-
this._logDebug(
110-
`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'
111-
}(${xhr.readyState}), status: ${xhr.status}`
112-
);
106+
this._logDebug(`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[xhr.readyState] || 'Unknown'}(${xhr.readyState}), status: ${xhr.status}`);
113107

114-
if (
115-
![XMLHttpRequest.DONE, XMLHttpRequest.LOADING].includes(
116-
xhr.readyState
117-
)
118-
) {
108+
if (![XMLHttpRequest.DONE, XMLHttpRequest.LOADING].includes(xhr.readyState)) {
119109
return;
120110
}
121111

122112
if (xhr.status >= 200 && xhr.status < 400) {
123113
if (this.status === this.CONNECTING) {
124114
this.status = this.OPEN;
125115
this.dispatch('open', { type: 'open' });
126-
this._logDebug(
127-
'[EventSource][onreadystatechange][OPEN] Connection opened.'
128-
);
116+
this._logDebug('[EventSource][onreadystatechange][OPEN] Connection opened.');
129117
}
130118

131119
this._handleEvent(xhr.responseText || '');
132120

133121
if (xhr.readyState === XMLHttpRequest.DONE) {
134-
this._logDebug(
135-
'[EventSource][onreadystatechange][DONE] Operation done.'
136-
);
122+
this._logDebug('[EventSource][onreadystatechange][DONE] Operation done.');
137123
this._pollAgain(this.interval, false);
138124
}
139125
} else if (xhr.status !== 0) {
@@ -146,9 +132,7 @@ class EventSource {
146132
});
147133

148134
if (xhr.readyState === XMLHttpRequest.DONE) {
149-
this._logDebug(
150-
'[EventSource][onreadystatechange][ERROR] Response status error.'
151-
);
135+
this._logDebug('[EventSource][onreadystatechange][ERROR] Response status error.');
152136
this._pollAgain(this.interval, false);
153137
}
154138
}
@@ -202,16 +186,10 @@ class EventSource {
202186
if (this.lineEndingCharacter === null) {
203187
const detectedNewlineChar = this._detectNewlineChar(response);
204188
if (detectedNewlineChar !== null) {
205-
this._logDebug(
206-
`[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(
207-
detectedNewlineChar
208-
).slice(1, -1)}`
209-
);
189+
this._logDebug(`[EventSource] Automatically detected lineEndingCharacter: ${JSON.stringify(detectedNewlineChar).slice(1, -1)}`);
210190
this.lineEndingCharacter = detectedNewlineChar;
211191
} else {
212-
console.warn(
213-
'[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\r\\n, \\n, \\r, or specify your custom character using the 'lineEndingCharacter' option.'
214-
);
192+
console.warn("[EventSource] Unable to identify the line ending character. Ensure your server delivers a standard line ending character: \\r\\n, \\n, \\r, or specify your custom character using the 'lineEndingCharacter' option.");
215193
return;
216194
}
217195
}
@@ -221,9 +199,7 @@ class EventSource {
221199
return;
222200
}
223201

224-
const parts = response
225-
.substring(this._lastIndexProcessed, indexOfDoubleNewline)
226-
.split(this.lineEndingCharacter);
202+
const parts = response.substring(this._lastIndexProcessed, indexOfDoubleNewline).split(this.lineEndingCharacter);
227203

228204
this._lastIndexProcessed = indexOfDoubleNewline;
229205

@@ -281,8 +257,7 @@ class EventSource {
281257
}
282258

283259
_getLastDoubleNewlineIndex(response) {
284-
const doubleLineEndingCharacter =
285-
this.lineEndingCharacter + this.lineEndingCharacter;
260+
const doubleLineEndingCharacter = this.lineEndingCharacter + this.lineEndingCharacter;
286261
const lastIndex = response.lastIndexOf(doubleLineEndingCharacter);
287262
if (lastIndex === -1) {
288263
return -1;
@@ -301,9 +276,7 @@ class EventSource {
301276

302277
removeEventListener(type, listener) {
303278
if (this.eventHandlers[type] !== undefined) {
304-
this.eventHandlers[type] = this.eventHandlers[type].filter(
305-
(handler) => handler !== listener
306-
);
279+
this.eventHandlers[type] = this.eventHandlers[type].filter((handler) => handler !== listener);
307280
}
308281
}
309282

@@ -316,9 +289,7 @@ class EventSource {
316289
}
317290
} else {
318291
if (!availableTypes.includes(type)) {
319-
throw Error(
320-
`[EventSource] '${type}' type is not supported event type.`
321-
);
292+
throw Error(`[EventSource] '${type}' type is not supported event type.`);
322293
}
323294

324295
this.eventHandlers[type] = [];

0 commit comments

Comments
 (0)