[MessageHandler] Convert all instances of var
to const
in the code
This commit is contained in:
parent
f61fb3e0f9
commit
5d5733c0a7
@ -198,6 +198,7 @@
|
|||||||
"object-shorthand": ["error", "always", {
|
"object-shorthand": ["error", "always", {
|
||||||
"avoidQuotes": true,
|
"avoidQuotes": true,
|
||||||
}],
|
}],
|
||||||
|
"prefer-const": "off",
|
||||||
"rest-spread-spacing": ["error", "never"],
|
"rest-spread-spacing": ["error", "never"],
|
||||||
"sort-imports": ["error", {
|
"sort-imports": ["error", {
|
||||||
"ignoreCase": true,
|
"ignoreCase": true,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-var: error, prefer-const: error */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AbortException, assert, createPromiseCapability, MissingPDFException,
|
AbortException, assert, createPromiseCapability, MissingPDFException,
|
||||||
@ -171,8 +172,8 @@ MessageHandler.prototype = {
|
|||||||
* @returns {Promise} Promise to be resolved with response data.
|
* @returns {Promise} Promise to be resolved with response data.
|
||||||
*/
|
*/
|
||||||
sendWithPromise(actionName, data, transfers) {
|
sendWithPromise(actionName, data, transfers) {
|
||||||
var callbackId = this.callbackId++;
|
const callbackId = this.callbackId++;
|
||||||
var capability = createPromiseCapability();
|
const capability = createPromiseCapability();
|
||||||
this.callbackCapabilities[callbackId] = capability;
|
this.callbackCapabilities[callbackId] = capability;
|
||||||
try {
|
try {
|
||||||
this.postMessage({
|
this.postMessage({
|
||||||
@ -198,14 +199,14 @@ MessageHandler.prototype = {
|
|||||||
* @returns {ReadableStream} ReadableStream to read data in chunks.
|
* @returns {ReadableStream} ReadableStream to read data in chunks.
|
||||||
*/
|
*/
|
||||||
sendWithStream(actionName, data, queueingStrategy, transfers) {
|
sendWithStream(actionName, data, queueingStrategy, transfers) {
|
||||||
let streamId = this.streamId++;
|
const streamId = this.streamId++;
|
||||||
let sourceName = this.sourceName;
|
const sourceName = this.sourceName;
|
||||||
let targetName = this.targetName;
|
const targetName = this.targetName;
|
||||||
const comObj = this.comObj;
|
const comObj = this.comObj;
|
||||||
|
|
||||||
return new ReadableStream({
|
return new ReadableStream({
|
||||||
start: (controller) => {
|
start: (controller) => {
|
||||||
let startCapability = createPromiseCapability();
|
const startCapability = createPromiseCapability();
|
||||||
this.streamControllers[streamId] = {
|
this.streamControllers[streamId] = {
|
||||||
controller,
|
controller,
|
||||||
startCall: startCapability,
|
startCall: startCapability,
|
||||||
@ -226,7 +227,7 @@ MessageHandler.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
pull: (controller) => {
|
pull: (controller) => {
|
||||||
let pullCapability = createPromiseCapability();
|
const pullCapability = createPromiseCapability();
|
||||||
this.streamControllers[streamId].pullCall = pullCapability;
|
this.streamControllers[streamId].pullCall = pullCapability;
|
||||||
comObj.postMessage({
|
comObj.postMessage({
|
||||||
sourceName,
|
sourceName,
|
||||||
@ -242,7 +243,7 @@ MessageHandler.prototype = {
|
|||||||
|
|
||||||
cancel: (reason) => {
|
cancel: (reason) => {
|
||||||
assert(reason instanceof Error, 'cancel must have a valid reason');
|
assert(reason instanceof Error, 'cancel must have a valid reason');
|
||||||
let cancelCapability = createPromiseCapability();
|
const cancelCapability = createPromiseCapability();
|
||||||
this.streamControllers[streamId].cancelCall = cancelCapability;
|
this.streamControllers[streamId].cancelCall = cancelCapability;
|
||||||
this.streamControllers[streamId].isClosed = true;
|
this.streamControllers[streamId].isClosed = true;
|
||||||
comObj.postMessage({
|
comObj.postMessage({
|
||||||
@ -259,21 +260,19 @@ MessageHandler.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_createStreamSink(data) {
|
_createStreamSink(data) {
|
||||||
let self = this;
|
const self = this;
|
||||||
let action = this.actionHandler[data.action];
|
const action = this.actionHandler[data.action];
|
||||||
let streamId = data.streamId;
|
const streamId = data.streamId;
|
||||||
let desiredSize = data.desiredSize;
|
const sourceName = this.sourceName;
|
||||||
let sourceName = this.sourceName;
|
const targetName = data.sourceName;
|
||||||
let targetName = data.sourceName;
|
|
||||||
let capability = createPromiseCapability();
|
|
||||||
const comObj = this.comObj;
|
const comObj = this.comObj;
|
||||||
|
|
||||||
let streamSink = {
|
const streamSink = {
|
||||||
enqueue(chunk, size = 1, transfers) {
|
enqueue(chunk, size = 1, transfers) {
|
||||||
if (this.isCancelled) {
|
if (this.isCancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let lastDesiredSize = this.desiredSize;
|
const lastDesiredSize = this.desiredSize;
|
||||||
this.desiredSize -= size;
|
this.desiredSize -= size;
|
||||||
// Enqueue decreases the desiredSize property of sink,
|
// Enqueue decreases the desiredSize property of sink,
|
||||||
// so when it changes from positive to negative,
|
// so when it changes from positive to negative,
|
||||||
@ -320,11 +319,11 @@ MessageHandler.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
sinkCapability: capability,
|
sinkCapability: createPromiseCapability(),
|
||||||
onPull: null,
|
onPull: null,
|
||||||
onCancel: null,
|
onCancel: null,
|
||||||
isCancelled: false,
|
isCancelled: false,
|
||||||
desiredSize,
|
desiredSize: data.desiredSize,
|
||||||
ready: null,
|
ready: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -353,9 +352,9 @@ MessageHandler.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_processStreamMessage(data) {
|
_processStreamMessage(data) {
|
||||||
let sourceName = this.sourceName;
|
|
||||||
let targetName = data.sourceName;
|
|
||||||
const streamId = data.streamId;
|
const streamId = data.streamId;
|
||||||
|
const sourceName = this.sourceName;
|
||||||
|
const targetName = data.sourceName;
|
||||||
const comObj = this.comObj;
|
const comObj = this.comObj;
|
||||||
|
|
||||||
switch (data.stream) {
|
switch (data.stream) {
|
||||||
|
Loading…
Reference in New Issue
Block a user