diff --git a/js/.prettierrc b/js/.prettierrc index 7ebc39f8246..354533b348f 100644 --- a/js/.prettierrc +++ b/js/.prettierrc @@ -2,3 +2,6 @@ overrides: - files: [".eslintrc.js", "*.json"] options: quoteProps: preserve + - files: ["*.js"] + options: + arrowParens: avoid diff --git a/js/dts-bundle.js b/js/dts-bundle.js index d7994f9fbc5..4c0300de308 100644 --- a/js/dts-bundle.js +++ b/js/dts-bundle.js @@ -27,20 +27,20 @@ function collectReferences(filePath) { const fileContent = fs.readFileSync(filePath, "utf-8"); const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true); - sourceFile.referencedFiles.forEach((reference) => { + sourceFile.referencedFiles.forEach(reference => { const referencePath = path.resolve(path.dirname(filePath), reference.fileName); collectReferences(referencePath); }); - sourceFile.forEachChild((node) => { + sourceFile.forEachChild(node => { if (ts.isModuleDeclaration(node)) { const moduleName = node.name.getText(); const moduleBody = node.body; if (moduleBody && ts.isModuleBlock(moduleBody)) { const moduleContent = moduleBody.statements - .filter((stmt) => !ts.isImportEqualsDeclaration(stmt)) - .map((stmt) => stmt.getText()) + .filter(stmt => !ts.isImportEqualsDeclaration(stmt)) + .map(stmt => stmt.getText()) .join("\n"); if (!moduleDeclarations.has(moduleName)) { diff --git a/js/gulpfile.js b/js/gulpfile.js index 7ff578006f5..850a419dc27 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -21,7 +21,7 @@ import tsc from "gulp-typescript"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const iceBinDist = (process.env.ICE_BIN_DIST || "").split(" "); -const useBinDist = iceBinDist.find((v) => v == "js" || v == "all") !== undefined; +const useBinDist = iceBinDist.find(v => v == "js" || v == "all") !== undefined; function parseArg(argv, key) { for (let i = 0; i < argv.length; ++i) { @@ -80,14 +80,14 @@ const excludes = { }; function createCleanTask(taskName, patterns, extension, dest = undefined) { - gulp.task(taskName, async (cb) => { + gulp.task(taskName, async cb => { const pumpArgs = [gulp.src(patterns), extReplace(extension)]; if (dest !== undefined) { pumpArgs.push(gulp.dest(dest)); } pumpArgs.push(vinylPaths(deleteAsync)); return new Promise((resolve, reject) => { - pump(pumpArgs, (err) => { + pump(pumpArgs, err => { if (err) { reject(err); } else { @@ -100,7 +100,7 @@ function createCleanTask(taskName, patterns, extension, dest = undefined) { for (const lib of libs) { const slicePatterns = [`../slice/${lib}/*.ice`, ...(excludes[lib] || [])]; - gulp.task(libTask(lib, "generate"), (cb) => { + gulp.task(libTask(lib, "generate"), cb => { pump( [ gulp.src(slicePatterns), @@ -122,20 +122,20 @@ for (const lib of libs) { } if (useBinDist) { - gulp.task("ice:module", (cb) => cb()); - gulp.task("ice:module:clean", (cb) => cb()); - gulp.task("dist", (cb) => cb()); - gulp.task("dist:clean", (cb) => cb()); + gulp.task("ice:module", cb => cb()); + gulp.task("ice:module:clean", cb => cb()); + gulp.task("dist", cb => cb()); + gulp.task("dist:clean", cb => cb()); } else { - gulp.task("dist", gulp.parallel(libs.map((libName) => libTask(libName, "generate")))); + gulp.task("dist", gulp.parallel(libs.map(libName => libTask(libName, "generate")))); - gulp.task("dist:clean", gulp.parallel(libs.map((libName) => libTask(libName, "clean")))); + gulp.task("dist:clean", gulp.parallel(libs.map(libName => libTask(libName, "clean")))); gulp.task("ice:module:package", () => gulp.src(["package.json"]).pipe(gulp.dest("node_modules/ice"))); gulp.task( "ice:module", - gulp.series("ice:module:package", (cb) => { + gulp.series("ice:module:package", cb => { pump([gulp.src([`${root}/src/**/*`]), gulp.dest(`${root}/node_modules/ice/src`)], cb); }), ); @@ -175,7 +175,7 @@ const tests = [ "test/Slice/macros", ]; -gulp.task("test:common:generate", (cb) => { +gulp.task("test:common:generate", cb => { pump([gulp.src(["../scripts/Controller.ice"]), slice2js(), gulp.dest("test/Common")], cb); }); @@ -194,7 +194,7 @@ function NodeMockupResolver() { }; } -gulp.task("ice:bundle", (cb) => { +gulp.task("ice:bundle", cb => { return new Promise(async (resolve, reject) => { try { let bundle = await rollup({ @@ -225,7 +225,7 @@ function IceResolver() { }; } -gulp.task("test:common:bundle", (cb) => { +gulp.task("test:common:bundle", cb => { return new Promise(async (resolve, reject) => { try { let bundle = await rollup({ @@ -245,7 +245,7 @@ gulp.task("test:common:bundle", (cb) => { }); }); -gulp.task("test:common:clean", (cb) => { +gulp.task("test:common:clean", cb => { deleteAsync(["test/Common/Controller.js", "test/Common/.depend"]); cb(); }); @@ -253,7 +253,7 @@ gulp.task("test:common:clean", (cb) => { const testTask = (testName, taskName) => testName.replace(/\//g, "_") + ":" + taskName; for (const name of tests) { - gulp.task(testTask(name, "build"), (cb) => { + gulp.task(testTask(name, "build"), cb => { const outputDirectory = `${root}/${name}`; pump( [ @@ -270,7 +270,7 @@ for (const name of tests) { ); }); - gulp.task(testTask(name, "ts-compile"), (cb) => { + gulp.task(testTask(name, "ts-compile"), cb => { pump( [ gulp.src([`${root}/${name}/*.ts`, `!${root}/${name}/*.d.ts`]), @@ -287,7 +287,7 @@ for (const name of tests) { ); }); - gulp.task(testTask(name, "bundle"), async (cb) => { + gulp.task(testTask(name, "bundle"), async cb => { let input = fs.existsSync(`${name}/index.js`) ? `${name}/index.js` : `${name}/Client.js`; let bundle = await rollup({ @@ -300,7 +300,7 @@ for (const name of tests) { }); }); - gulp.task(testTask(name, "copy:assets"), async (cb) => { + gulp.task(testTask(name, "copy:assets"), async cb => { pump([gulp.src("test/Common/controller.html"), gulp.dest(`dist/${name}`)], cb); }); @@ -320,10 +320,10 @@ gulp.task( "ice:bundle", "test:common:generate", "test:common:bundle", - gulp.series(tests.map((testName) => testTask(testName, "build"))), - gulp.series(tests.map((testName) => testTask(testName, "ts-compile"))), - gulp.series(tests.map((testName) => testTask(testName, "bundle"))), - gulp.series(tests.map((testName) => testTask(testName, "copy:assets"))), + gulp.series(tests.map(testName => testTask(testName, "build"))), + gulp.series(tests.map(testName => testTask(testName, "ts-compile"))), + gulp.series(tests.map(testName => testTask(testName, "bundle"))), + gulp.series(tests.map(testName => testTask(testName, "copy:assets"))), ), ); @@ -334,7 +334,7 @@ gulp.task( gulp.series( "test:common:clean", "test:bundle:clean", - tests.map((testName) => testTask(testName, "clean")), + tests.map(testName => testTask(testName, "clean")), ), ); diff --git a/js/src/Ice/ConnectRequestHandler.js b/js/src/Ice/ConnectRequestHandler.js index bf863d9cf5a..738cdd36b96 100644 --- a/js/src/Ice/ConnectRequestHandler.js +++ b/js/src/Ice/ConnectRequestHandler.js @@ -74,7 +74,7 @@ export class ConnectRequestHandler { ri.addProxy(this._reference).then( // The proxy was added to the router info, we're now ready to send the queued requests. () => this.flushRequests(), - (ex) => this.setException(ex), + ex => this.setException(ex), ); return; // The request handler will be initialized once addProxy completes. } diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index ccfc64eb07b..3ef6e34d539 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -244,7 +244,7 @@ export class ConnectionI { // Timer.setImmediate(() => { this.setState(StateClosing, new ConnectionManuallyClosedException(true)); - this._closePromises.forEach((p) => p.resolve()); + this._closePromises.forEach(p => p.resolve()); this._closePromises = []; }); } @@ -1512,7 +1512,7 @@ export class ConnectionI { // Clear the OA. See bug 1673 for the details of why this is necessary. // this._adapter = null; - this._finishedPromises.forEach((p) => p.resolve()); + this._finishedPromises.forEach(p => p.resolve()); this._finishedPromises = []; } } diff --git a/js/src/Ice/EndpointFactoryManager.js b/js/src/Ice/EndpointFactoryManager.js index 76598c7fd00..67561b0bdf7 100644 --- a/js/src/Ice/EndpointFactoryManager.js +++ b/js/src/Ice/EndpointFactoryManager.js @@ -16,12 +16,12 @@ export class EndpointFactoryManager { } add(factory) { - Debug.assert(this._factories.find((f) => factory.type() == f.type()) === undefined); + Debug.assert(this._factories.find(f => factory.type() == f.type()) === undefined); this._factories.push(factory); } get(type) { - return this._factories.find((f) => type == f.type()) || null; + return this._factories.find(f => type == f.type()) || null; } create(str, oaEndpoint) { @@ -113,7 +113,7 @@ export class EndpointFactoryManager { } destroy() { - this._factories.forEach((factory) => factory.destroy()); + this._factories.forEach(factory => factory.destroy()); this._factories = []; } } diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js index c25497007b3..de7aacdbc88 100644 --- a/js/src/Ice/IncomingAsync.js +++ b/js/src/Ice/IncomingAsync.js @@ -354,7 +354,7 @@ export class IncomingAsync { if (promise !== null) { promise.then( () => this.completed(null), - (ex) => this.completed(ex), + ex => this.completed(ex), ); return; } diff --git a/js/src/Ice/InstanceExtensions.js b/js/src/Ice/InstanceExtensions.js index fe9214440a1..8d5bdd12b09 100644 --- a/js/src/Ice/InstanceExtensions.js +++ b/js/src/Ice/InstanceExtensions.js @@ -394,7 +394,7 @@ Instance.prototype.destroy = function () { } if (this._objectFactoryMap !== null) { - this._objectFactoryMap.forEach((factory) => factory.destroy()); + this._objectFactoryMap.forEach(factory => factory.destroy()); this._objectFactoryMap.clear(); } @@ -413,7 +413,7 @@ Instance.prototype.destroy = function () { if (unusedProperties.length > 0) { const message = []; message.push("The following properties were set but never read:"); - unusedProperties.forEach((p) => message.push("\n ", p)); + unusedProperties.forEach(p => message.push("\n ", p)); this._initData.logger.warning(message.join("")); } } @@ -431,13 +431,13 @@ Instance.prototype.destroy = function () { this._state = StateDestroyed; if (this._destroyPromises) { - this._destroyPromises.forEach((p) => p.resolve()); + this._destroyPromises.forEach(p => p.resolve()); } promise.resolve(); }) - .catch((ex) => { + .catch(ex => { if (this._destroyPromises) { - this._destroyPromises.forEach((p) => p.reject(ex)); + this._destroyPromises.forEach(p => p.reject(ex)); } promise.reject(ex); }); diff --git a/js/src/Ice/LocatorInfo.js b/js/src/Ice/LocatorInfo.js index c42a40b0453..254b5de2a1a 100644 --- a/js/src/Ice/LocatorInfo.js +++ b/js/src/Ice/LocatorInfo.js @@ -54,7 +54,7 @@ export class LocatorInfo { return Promise.resolve(this._locatorRegistry); } - return this._locator.getRegistry().then((reg) => { + return this._locator.getRegistry().then(reg => { // // The locator registry can't be located. We use ordered // endpoint selection in case the locator returned a proxy @@ -157,7 +157,7 @@ export class LocatorInfo { } s.push("endpoints = "); - s.push(endpoints.map((e) => e.toString()).join(":")); + s.push(endpoints.map(e => e.toString()).join(":")); ref.getInstance().initializationData().logger.trace(ref.getInstance().traceLevels().locationCat, s.join("")); } @@ -378,12 +378,12 @@ class RequestCallback { ); } locatorInfo.getEndpoints(r, this._ref, this._ttl).then( - (values) => { + values => { if (this._promise !== null) { this._promise.resolve(values); } }, - (ex) => { + ex => { if (this._promise !== null) { this._promise.reject(ex); } @@ -475,8 +475,8 @@ class ObjectRequest extends Request { .getLocator() .findObjectById(this._ref.getIdentity()) .then( - (proxy) => this.response(proxy), - (ex) => this.exception(ex), + proxy => this.response(proxy), + ex => this.exception(ex), ); } catch (ex) { this.exception(ex); @@ -496,8 +496,8 @@ class AdapterRequest extends Request { .getLocator() .findAdapterById(this._ref.getAdapterId()) .then( - (proxy) => this.response(proxy), - (ex) => this.exception(ex), + proxy => this.response(proxy), + ex => this.exception(ex), ); } catch (ex) { this.exception(ex); diff --git a/js/src/Ice/ObjectAdapter.js b/js/src/Ice/ObjectAdapter.js index b4b4b5f31f6..00bd54a5346 100644 --- a/js/src/Ice/ObjectAdapter.js +++ b/js/src/Ice/ObjectAdapter.js @@ -104,7 +104,7 @@ export class ObjectAdapter { // if (unknownProps.length !== 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { const message = ["found unknown properties for object adapter `" + name + "':"]; - unknownProps.forEach((unknownProp) => message.push("\n " + unknownProp)); + unknownProps.forEach(unknownProp => message.push("\n " + unknownProp)); this._instance.initializationData().logger.warning(message.join("")); } @@ -183,11 +183,11 @@ export class ObjectAdapter { } p.then(() => this.computePublishedEndpoints()).then( - (endpoints) => { + endpoints => { this._publishedEndpoints = endpoints; promise.resolve(this); }, - (ex) => { + ex => { this.destroy(); promise.reject(ex); }, @@ -389,7 +389,7 @@ export class ObjectAdapter { refreshPublishedEndpoints() { this.checkForDeactivation(); - return this.computePublishedEndpoints().then((endpoints) => { + return this.computePublishedEndpoints().then(endpoints => { this._publishedEndpoints = endpoints; }); } @@ -464,13 +464,13 @@ export class ObjectAdapter { computePublishedEndpoints() { let p; if (this._routerInfo !== null) { - p = this._routerInfo.getServerEndpoints().then((endpts) => { + p = this._routerInfo.getServerEndpoints().then(endpts => { // // Remove duplicate endpoints, so we have a list of unique endpoints. // const endpoints = []; - endpts.forEach((endpoint) => { - if (endpoints.findIndex((value) => endpoint.equals(value)) === -1) { + endpts.forEach(endpoint => { + if (endpoints.findIndex(value => endpoint.equals(value)) === -1) { endpoints.push(endpoint); } }); @@ -538,14 +538,14 @@ export class ObjectAdapter { p = Promise.resolve(endpoints); } - return p.then((endpoints) => { + return p.then(endpoints => { if (this._instance.traceLevels().network >= 1 && endpoints.length > 0) { const s = []; s.push("published endpoints for object adapter `"); s.push(this._name); s.push("':\n"); let first = true; - endpoints.forEach((endpoint) => { + endpoints.forEach(endpoint => { if (!first) { s.push(":"); } @@ -598,14 +598,14 @@ export class ObjectAdapter { this._state = state; let promises = []; - (state < StateDeactivated ? [state] : [StateHeld, StateDeactivated]).forEach((s) => { + (state < StateDeactivated ? [state] : [StateHeld, StateDeactivated]).forEach(s => { if (this._statePromises[s]) { promises = promises.concat(this._statePromises[s]); delete this._statePromises[s]; } }); if (promises.length > 0) { - Timer.setImmediate(() => promises.forEach((p) => p.resolve())); + Timer.setImmediate(() => promises.forEach(p => p.resolve())); } } diff --git a/js/src/Ice/ObjectAdapterFactory.js b/js/src/Ice/ObjectAdapterFactory.js index 50353d4424e..4f8c3ca365f 100644 --- a/js/src/Ice/ObjectAdapterFactory.js +++ b/js/src/Ice/ObjectAdapterFactory.js @@ -30,13 +30,13 @@ export class ObjectAdapterFactory { this._instance = null; this._communicator = null; - Promise.all(this._adapters.map((adapter) => adapter.deactivate())).then(() => this._shutdownPromise.resolve()); + Promise.all(this._adapters.map(adapter => adapter.deactivate())).then(() => this._shutdownPromise.resolve()); return this._shutdownPromise; } waitForShutdown() { return this._shutdownPromise.then(() => - Promise.all(this._adapters.map((adapter) => adapter.waitForDeactivate())), + Promise.all(this._adapters.map(adapter => adapter.waitForDeactivate())), ); } @@ -45,7 +45,7 @@ export class ObjectAdapterFactory { } destroy() { - return this.waitForShutdown().then(() => Promise.all(this._adapters.map((adapter) => adapter.destroy()))); + return this.waitForShutdown().then(() => Promise.all(this._adapters.map(adapter => adapter.destroy()))); } createObjectAdapter(name, router, promise) { diff --git a/js/src/Ice/ObjectPrxExtensions.js b/js/src/Ice/ObjectPrxExtensions.js index 7f874748878..c87643097c7 100644 --- a/js/src/Ice/ObjectPrxExtensions.js +++ b/js/src/Ice/ObjectPrxExtensions.js @@ -410,7 +410,7 @@ ObjectPrx._invoke = function (p, name, mode, fmt, ctx, marshalFn, unmarshalFn, u p._checkAsyncTwowayOnly(name); } - const r = new OutgoingAsync(p, name, (res) => { + const r = new OutgoingAsync(p, name, res => { this._completed(res, unmarshalFn, userEx); }); diff --git a/js/src/Ice/Operation.js b/js/src/Ice/Operation.js index afbbe8ca08e..30a85773bb5 100644 --- a/js/src/Ice/Operation.js +++ b/js/src/Ice/Operation.js @@ -166,7 +166,7 @@ function unmarshalParams(is, retvalInfo, allParamInfo, optParamInfo, usesClasses params[p.pos + offset] = p.type.readOptional(is, p.tag); } } else if (p.isObject) { - is.readValue((obj) => { + is.readValue(obj => { params[p.pos + offset] = obj; }, p.type); } else { diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js index 4afeb153849..815de0027be 100644 --- a/js/src/Ice/OutgoingAsync.js +++ b/js/src/Ice/OutgoingAsync.js @@ -576,7 +576,7 @@ export class ProxyFlushBatch extends ProxyOutgoingAsyncBase { export class ProxyGetConnection extends ProxyOutgoingAsyncBase { invokeRemote(connection, response) { - this.markFinished(true, (r) => r.resolve(connection)); + this.markFinished(true, r => r.resolve(connection)); return AsyncStatus.Sent; } diff --git a/js/src/Ice/OutgoingConnectionFactory.js b/js/src/Ice/OutgoingConnectionFactory.js index 2f4b4ff7b7a..70130f7421b 100644 --- a/js/src/Ice/OutgoingConnectionFactory.js +++ b/js/src/Ice/OutgoingConnectionFactory.js @@ -32,7 +32,7 @@ export class OutgoingConnectionFactory { return; } - this._connectionsByEndpoint.forEach((connection) => connection.destroy(ConnectionI.CommunicatorDestroyed)); + this._connectionsByEndpoint.forEach(connection => connection.destroy(ConnectionI.CommunicatorDestroyed)); this._destroyed = true; this._communicator = null; @@ -72,7 +72,7 @@ export class OutgoingConnectionFactory { throw new CommunicatorDestroyedException(); } return routerInfo.getClientEndpoints(); - }).then((endpoints) => { + }).then(endpoints => { // // Search for connections to the router's client proxy // endpoints, and update the object adapter for such @@ -80,7 +80,7 @@ export class OutgoingConnectionFactory { // received over such connections. // const adapter = routerInfo.getAdapter(); - endpoints.forEach((endpoint) => { + endpoints.forEach(endpoint => { // // The Connection object does not take the compression flag of // endpoints into account, but instead gets the information @@ -92,7 +92,7 @@ export class OutgoingConnectionFactory { // endpoint = endpoint.changeCompress(false); - this._connectionsByEndpoint.forEach((connection) => { + this._connectionsByEndpoint.forEach(connection => { if (connection.endpoint().equals(endpoint)) { connection.setAdapter(adapter); } @@ -105,7 +105,7 @@ export class OutgoingConnectionFactory { if (this._destroyed) { return; } - this._connectionsByEndpoint.forEach((connection) => { + this._connectionsByEndpoint.forEach(connection => { if (connection.getAdapter() === adapter) { connection.setAdapter(null); } @@ -120,9 +120,9 @@ export class OutgoingConnectionFactory { } Promise.all( - this._connectionsByEndpoint.map((connection) => { + this._connectionsByEndpoint.map(connection => { if (connection.isActiveOrHolding()) { - return connection.flushBatchRequests().catch((ex) => { + return connection.flushBatchRequests().catch(ex => { if (ex instanceof LocalException) { // Ignore } else { @@ -254,7 +254,7 @@ export class OutgoingConnectionFactory { this._instance, transceiver, endpoint.changeCompress(false).changeTimeout(-1), - (connection) => this.removeConnection(connection), + connection => this.removeConnection(connection), this._connectionOptions, ); } catch (ex) { @@ -287,11 +287,11 @@ export class OutgoingConnectionFactory { } const callbacks = []; - endpoints.forEach((endpt) => { + endpoints.forEach(endpt => { const cbs = this._pending.get(endpt); if (cbs !== undefined) { this._pending.delete(endpt); - cbs.forEach((cc) => { + cbs.forEach(cc => { if (cc.hasEndpoint(endpoint)) { if (connectionCallbacks.indexOf(cc) === -1) { connectionCallbacks.push(cc); @@ -303,7 +303,7 @@ export class OutgoingConnectionFactory { } }); - connectionCallbacks.forEach((cc) => { + connectionCallbacks.forEach(cc => { cc.removeFromPending(); const idx = callbacks.indexOf(cc); if (idx !== -1) { @@ -311,10 +311,10 @@ export class OutgoingConnectionFactory { } }); - callbacks.forEach((cc) => cc.removeFromPending()); + callbacks.forEach(cc => cc.removeFromPending()); - callbacks.forEach((cc) => cc.getConnection()); - connectionCallbacks.forEach((cc) => cc.setConnection(connection)); + callbacks.forEach(cc => cc.getConnection()); + connectionCallbacks.forEach(cc => cc.setConnection(connection)); this.checkFinished(); } @@ -328,11 +328,11 @@ export class OutgoingConnectionFactory { } const callbacks = []; - endpoints.forEach((endpt) => { + endpoints.forEach(endpt => { const cbs = this._pending.get(endpt); if (cbs !== undefined) { this._pending.delete(endpt); - cbs.forEach((cc) => { + cbs.forEach(cc => { if (cc.removeEndpoints(endpoints)) { if (failedCallbacks.indexOf(cc) === -1) { failedCallbacks.push(cc); @@ -344,13 +344,13 @@ export class OutgoingConnectionFactory { } }); - callbacks.forEach((cc) => { + callbacks.forEach(cc => { Debug.assert(failedCallbacks.indexOf(cc) === -1); cc.removeFromPending(); }); this.checkFinished(); - callbacks.forEach((cc) => cc.getConnection()); - failedCallbacks.forEach((cc) => cc.setException(ex)); + callbacks.forEach(cc => cc.getConnection()); + failedCallbacks.forEach(cc => cc.setException(ex)); } addToPending(cb, endpoints) { @@ -361,7 +361,7 @@ export class OutgoingConnectionFactory { // let found = false; if (cb !== null) { - endpoints.forEach((p) => { + endpoints.forEach(p => { const cbs = this._pending.get(p); if (cbs !== undefined) { found = true; @@ -381,7 +381,7 @@ export class OutgoingConnectionFactory { // responsible for its establishment. We add empty pending lists, // other callbacks to the same endpoints will be queued. // - endpoints.forEach((p) => { + endpoints.forEach(p => { if (!this._pending.has(p)) { this._pending.set(p, []); } @@ -392,7 +392,7 @@ export class OutgoingConnectionFactory { removeFromPending(cb, endpoints) { // cb is-a ConnectCallback - endpoints.forEach((p) => { + endpoints.forEach(p => { const cbs = this._pending.get(p); if (cbs !== undefined) { const idx = cbs.indexOf(cb); @@ -446,7 +446,7 @@ export class OutgoingConnectionFactory { } await Promise.all( - this._connectionsByEndpoint.map(async (connection) => { + this._connectionsByEndpoint.map(async connection => { try { await connection.waitUntilFinished(); } catch (ex) { @@ -492,7 +492,7 @@ class ConnectionListMap extends HashMap { map(fn) { const arr = []; - this.forEach((c) => arr.push(fn(c))); + this.forEach(c => arr.push(fn(c))); return arr; } @@ -551,11 +551,11 @@ class ConnectCallback { } findEndpoint(endpoint) { - return this._endpoints.findIndex((value) => endpoint.equals(value)); + return this._endpoints.findIndex(value => endpoint.equals(value)); } removeEndpoints(endpoints) { - endpoints.forEach((endpoint) => { + endpoints.forEach(endpoint => { const idx = this.findEndpoint(endpoint); if (idx !== -1) { this._endpoints.splice(idx, 1); @@ -611,12 +611,12 @@ class ConnectCallback { } nextEndpoint() { - const start = (connection) => { + const start = connection => { connection.start().then( () => { this.connectionStartCompleted(connection); }, - (ex) => { + ex => { this.connectionStartFailed(connection, ex); }, ); diff --git a/js/src/Ice/Promise.js b/js/src/Ice/Promise.js index 9ea1fe6532f..dfeefb7a57c 100644 --- a/js/src/Ice/Promise.js +++ b/js/src/Ice/Promise.js @@ -23,8 +23,8 @@ class P extends Promise { delay(ms) { return this.then( - (value) => new P((resolve, reject) => Timer.setTimeout(() => resolve(value), ms)), - (reason) => new P((resolve, reject) => Timer.setTimeout(() => reject(reason), ms)), + value => new P((resolve, reject) => Timer.setTimeout(() => resolve(value), ms)), + reason => new P((resolve, reject) => Timer.setTimeout(() => reject(reason), ms)), ); } @@ -33,7 +33,7 @@ class P extends Promise { } static delay(ms, value) { - return new P((resolve) => Timer.setTimeout(() => resolve(value), ms)); + return new P(resolve => Timer.setTimeout(() => resolve(value), ms)); } static try(cb) { diff --git a/js/src/Ice/Properties.js b/js/src/Ice/Properties.js index d77f1a74c96..87335cf1f18 100644 --- a/js/src/Ice/Properties.js +++ b/js/src/Ice/Properties.js @@ -177,7 +177,7 @@ export class Properties { const result = []; - options.forEach((opt) => { + options.forEach(opt => { if (opt.indexOf(pfx) === 0) { if (opt.indexOf("=") === -1) { opt += "=1"; @@ -200,7 +200,7 @@ export class Properties { } parse(data) { - data.match(/[^\r\n]+/g).forEach((line) => this.parseLine(line)); + data.match(/[^\r\n]+/g).forEach(line => this.parseLine(line)); } parseLine(line) { diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js index faafa77b265..8b8072a558d 100644 --- a/js/src/Ice/Reference.js +++ b/js/src/Ice/Reference.js @@ -871,7 +871,7 @@ export class RoutableReference extends Reference { changeConnectionId(id) { const r = this.getInstance().referenceFactory().copy(this); r._connectionId = id; - r._endpoints = this._endpoints.map((endpoint) => endpoint.changeConnectionId(id)); + r._endpoints = this._endpoints.map(endpoint => endpoint.changeConnectionId(id)); return r; } @@ -905,7 +905,7 @@ export class RoutableReference extends Reference { s.writeSize(this._endpoints.length); if (this._endpoints.length > 0) { Debug.assert(this._adapterId.length === 0); - this._endpoints.forEach((endpoint) => { + this._endpoints.forEach(endpoint => { s.writeShort(endpoint.type()); endpoint.streamWrite(s); }); @@ -925,7 +925,7 @@ export class RoutableReference extends Reference { const s = []; s.push(super.toString()); if (this._endpoints.length > 0) { - this._endpoints.forEach((endpoint) => { + this._endpoints.forEach(endpoint => { const endp = endpoint.toString(); if (endp !== null && endp.length > 0) { s.push(":"); @@ -1063,7 +1063,7 @@ export class RoutableReference extends Reference { // this._routerInfo .getClientEndpoints() - .then((endpoints) => { + .then(endpoints => { if (endpoints.length > 0) { this.applyOverrides(endpoints); this.createConnection(endpoints).then(p.resolve, p.reject); @@ -1076,7 +1076,7 @@ export class RoutableReference extends Reference { this.getConnectionNoRouterInfo(p); } - p.then((connection) => handler.setConnection(connection)).catch((ex) => handler.setException(ex)); + p.then(connection => handler.setConnection(connection)).catch(ex => handler.setException(ex)); return p; } @@ -1089,7 +1089,7 @@ export class RoutableReference extends Reference { if (this._locatorInfo !== null) { this._locatorInfo .getEndpoints(this, null, this._locatorCacheTimeout) - .then((values) => { + .then(values => { const [endpoints, cached] = values; if (endpoints.length === 0) { p.reject(new NoEndpointException(this.toString())); @@ -1097,7 +1097,7 @@ export class RoutableReference extends Reference { } this.applyOverrides(endpoints); - this.createConnection(endpoints).then(p.resolve, (ex) => { + this.createConnection(endpoints).then(p.resolve, ex => { if (ex instanceof NoEndpointException) { // // No need to retry if there's no endpoints. @@ -1176,7 +1176,7 @@ export class RoutableReference extends Reference { // // Filter out opaque endpoints or endpoints which can't connect. // - let endpoints = allEndpoints.filter((e) => !(e instanceof OpaqueEndpointI) && e.connectable()); + let endpoints = allEndpoints.filter(e => !(e instanceof OpaqueEndpointI) && e.connectable()); // // Filter out endpoints according to the mode of the reference. @@ -1188,7 +1188,7 @@ export class RoutableReference extends Reference { // // Filter out datagram endpoints. // - endpoints = endpoints.filter((e) => !e.datagram()); + endpoints = endpoints.filter(e => !e.datagram()); break; } @@ -1197,7 +1197,7 @@ export class RoutableReference extends Reference { // // Filter out non-datagram endpoints. // - endpoints = endpoints.filter((e) => e.datagram()); + endpoints = endpoints.filter(e => e.datagram()); break; } @@ -1236,7 +1236,7 @@ export class RoutableReference extends Reference { // const overrides = this.getInstance().defaultsAndOverrides(); if (overrides.overrideSecure ? overrides.overrideSecureValue : this.getSecure()) { - endpoints = endpoints.filter((e) => e.secure()); + endpoints = endpoints.filter(e => e.secure()); } else { const preferSecure = this.getPreferSecure(); const compare = (e1, e2) => { @@ -1274,8 +1274,8 @@ export class RoutableReference extends Reference { const cb = new CreateConnectionCallback(this, null, promise); factory .create(endpoints, false, this.getEndpointSelection()) - .then((connection) => cb.setConnection(connection)) - .catch((ex) => cb.setException(ex)); + .then(connection => cb.setConnection(connection)) + .catch(ex => cb.setException(ex)); } else { // // Go through the list of endpoints and try to create the @@ -1287,8 +1287,8 @@ export class RoutableReference extends Reference { const cb = new CreateConnectionCallback(this, endpoints, promise); factory .create([endpoints[0]], true, this.getEndpointSelection()) - .then((connection) => cb.setConnection(connection)) - .catch((ex) => cb.setException(ex)); + .then(connection => cb.setConnection(connection)) + .catch(ex => cb.setException(ex)); } return promise; } @@ -1329,7 +1329,7 @@ class CreateConnectionCallback { .getInstance() .outgoingConnectionFactory() .create([this.endpoints[this.i]], this.i != this.endpoints.length - 1, this.ref.getEndpointSelection()) - .then((connection) => this.setConnection(connection)) - .catch((ex) => this.setException(ex)); + .then(connection => this.setConnection(connection)) + .catch(ex => this.setException(ex)); } } diff --git a/js/src/Ice/ReferenceFactory.js b/js/src/Ice/ReferenceFactory.js index 8a740571ffd..1389c1d1ea3 100644 --- a/js/src/Ice/ReferenceFactory.js +++ b/js/src/Ice/ReferenceFactory.js @@ -421,7 +421,7 @@ export class ReferenceFactory { ) { const msg = []; msg.push("Proxy contains unknown endpoints:"); - unknownEndpoints.forEach((unknownEndpoint) => { + unknownEndpoints.forEach(unknownEndpoint => { msg.push(" `"); msg.push(unknownEndpoint); msg.push("'"); @@ -593,7 +593,7 @@ export class ReferenceFactory { message.push("found unknown properties for proxy '"); message.push(prefix); message.push("':"); - unknownProps.forEach((unknownProp) => message.push("\n ", unknownProp)); + unknownProps.forEach(unknownProp => message.push("\n ", unknownProp)); this._instance.initializationData().logger.warning(message.join("")); } } diff --git a/js/src/Ice/RetryQueue.js b/js/src/Ice/RetryQueue.js index d9ad1fa9c31..67f86ce6362 100644 --- a/js/src/Ice/RetryQueue.js +++ b/js/src/Ice/RetryQueue.js @@ -53,7 +53,7 @@ export class RetryQueue { } destroy() { - this._requests.forEach((request) => { + this._requests.forEach(request => { this._instance.timer().cancel(request.token); request.destroy(); }); diff --git a/js/src/Ice/RouterInfo.js b/js/src/Ice/RouterInfo.js index eac3546e7e0..a4d225cbb95 100644 --- a/js/src/Ice/RouterInfo.js +++ b/js/src/Ice/RouterInfo.js @@ -54,16 +54,14 @@ export class RouterInfo { } else { this._router .getClientProxy() - .then((result) => - this.setClientEndpoints(result[0], result[1] !== undefined ? result[1] : true, promise), - ) + .then(result => this.setClientEndpoints(result[0], result[1] !== undefined ? result[1] : true, promise)) .catch(promise.reject); } return promise; } getServerEndpoints() { - return this._router.getServerProxy().then((serverProxy) => { + return this._router.getServerProxy().then(serverProxy => { if (serverProxy === null) { throw new NoEndpointException(); } @@ -81,7 +79,7 @@ export class RouterInfo { // Only add the proxy to the router if it's not already in our local map. return Promise.resolve(); } else { - return this._router.addProxies([new ObjectPrx(reference)]).then((evictedProxies) => { + return this._router.addProxies([new ObjectPrx(reference)]).then(evictedProxies => { this.addAndEvictProxies(identity, evictedProxies); }); } @@ -116,7 +114,7 @@ export class RouterInfo { // concurrent addProxies call. If it's the case, don't // add it to our local map. // - const index = this._evictedIdentities.findIndex((e) => e.equals(identity)); + const index = this._evictedIdentities.findIndex(e => e.equals(identity)); if (index >= 0) { this._evictedIdentities.splice(index, 1); } else { @@ -130,7 +128,7 @@ export class RouterInfo { // // We also must remove whatever proxies the router evicted. // - evictedProxies.forEach((proxy) => { + evictedProxies.forEach(proxy => { this._identities.delete(proxy.ice_getIdentity()); }); } diff --git a/js/src/Ice/Stream.js b/js/src/Ice/Stream.js index 3cb9996407a..46ddd0384e7 100644 --- a/js/src/Ice/Stream.js +++ b/js/src/Ice/Stream.js @@ -643,7 +643,7 @@ class EncapsDecoder11 extends EncapsDecoder { // Convert indirect references into direct references. // if (this._current.indirectPatchList !== null) { - this._current.indirectPatchList.forEach((e) => { + this._current.indirectPatchList.forEach(e => { Debug.assert(e.index >= 0); if (e.index >= indirectionTable.length) { throw new MarshalException("indirection out of range"); @@ -902,7 +902,7 @@ EncapsDecoder11.InstanceData = class { }; const sequencePatcher = function (seq, index, T) { - return (v) => { + return v => { if (v !== null && !(v instanceof T)) { throwUOE(T.ice_staticId(), v); } @@ -982,7 +982,7 @@ export class InputStream { // (encoding, buffer) // (encoding, buffer) // - arr.forEach((arg) => { + arr.forEach(arg => { if (arg !== null && arg !== undefined) { if (arg.constructor === Communicator) { args.instance = arg.instance; @@ -1512,7 +1512,7 @@ export class InputStream { readValue(cb, T) { this.initEncaps(); - this._encapsStack.decoder.readValue((obj) => { + this._encapsStack.decoder.readValue(obj => { if (obj !== null && !(obj instanceof T)) { throwUOE(T.ice_staticId(), obj); } @@ -2149,7 +2149,7 @@ class EncapsEncoder11 extends EncapsEncoder { // Write the indirection instance table. // this._stream.writeSize(this._current.indirectionTable.length); - this._current.indirectionTable.forEach((o) => this.writeInstance(o)); + this._current.indirectionTable.forEach(o => this.writeInstance(o)); this._current.indirectionTable.length = 0; // Faster way to clean array in JavaScript this._current.indirectionMap.clear(); } @@ -2186,7 +2186,7 @@ class EncapsEncoder11 extends EncapsEncoder { return; } - slicedData.slices.forEach((info) => { + slicedData.slices.forEach(info => { this.startSlice(info.typeId, info.compactId, info.isLastSlice); // @@ -2208,7 +2208,7 @@ class EncapsEncoder11 extends EncapsEncoder { this._current.indirectionMap = new Map(); // Map } - info.instances.forEach((instance) => this._current.indirectionTable.push(instance)); + info.instances.forEach(instance => this._current.indirectionTable.push(instance)); } this.endSlice(); @@ -2900,7 +2900,7 @@ export const ObjectHelper = class { static read(is) { let o; - is.readValue((v) => { + is.readValue(v => { o = v; }, Value); return o; diff --git a/js/src/Ice/StreamHelpers.js b/js/src/Ice/StreamHelpers.js index 76c2db3824a..52ecdefa9b8 100644 --- a/js/src/Ice/StreamHelpers.js +++ b/js/src/Ice/StreamHelpers.js @@ -121,7 +121,7 @@ class SequenceHelper { // Specialization optimized for ByteSeq const byteSeqHelper = new SequenceHelper(); byteSeqHelper.write = (os, v) => os.writeByteSeq(v); -byteSeqHelper.read = (is) => is.readByteSeq(); +byteSeqHelper.read = is => is.readByteSeq(); defineProperty(byteSeqHelper, "elementHelper", { get: () => ByteHelper }); StreamHelpers.VSizeContainer1OptHelper.call(byteSeqHelper); @@ -133,7 +133,7 @@ const valueSequenceHelperRead = function (is) { v.length = sz; const elementType = this.elementType; const readValueAtIndex = function (idx) { - is.readValue((obj) => { + is.readValue(obj => { v[idx] = obj; }, elementType); }; @@ -219,7 +219,7 @@ function valueDictionaryHelperRead(is) { const valueType = this.valueType; const readValueForKey = function (key) { - is.readValue((obj) => v.set(key, obj), valueType); + is.readValue(obj => v.set(key, obj), valueType); }; const keyHelper = this.keyHelper; diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js index 188e811a0f3..2034b7bf7db 100644 --- a/js/src/Ice/TcpTransceiver.js +++ b/js/src/Ice/TcpTransceiver.js @@ -55,7 +55,7 @@ if (typeof net.createConnection === "function") { }); this._fd.on("connect", () => this.socketConnected()); - this._fd.on("data", (buf) => this.socketBytesAvailable(buf)); + this._fd.on("data", buf => this.socketBytesAvailable(buf)); // // The error callback can be triggered from the socket @@ -64,8 +64,8 @@ if (typeof net.createConnection === "function") { // setImmediate. We do the same for close as a // precaution. See also issue #6226. // - this._fd.on("close", (err) => Timer.setImmediate(() => this.socketClosed(err))); - this._fd.on("error", (err) => Timer.setImmediate(() => this.socketError(err))); + this._fd.on("close", err => Timer.setImmediate(() => this.socketClosed(err))); + this._fd.on("error", err => Timer.setImmediate(() => this.socketError(err))); return SocketOperation.Connect; // Waiting for connect to complete. } else if (this._state === StateConnectPending) { diff --git a/js/src/Ice/TimerUtil.js b/js/src/Ice/TimerUtil.js index fc0e96368c3..56cfcaf5ce1 100644 --- a/js/src/Ice/TimerUtil.js +++ b/js/src/Ice/TimerUtil.js @@ -51,7 +51,7 @@ if (typeof process != "undefined") { // Only called for workers const channel = new MessageChannel(); - channel.port1.onmessage = (event) => { + channel.port1.onmessage = event => { const id = event.data; const cb = _timers.get(id); if (cb !== undefined) { @@ -135,7 +135,7 @@ if (typeof process != "undefined") { const timers = {}; - self.onmessage = (e) => { + self.onmessage = e => { if (e.data.type == _wSetTimeoutType) { timers[e.data.id] = setTimeout(() => self.postMessage(e.data), e.data.ms); } else if (e.data.type == _wSetIntervalType) { diff --git a/js/src/Ice/UUID.js b/js/src/Ice/UUID.js index 10a351cf2f4..f331474987f 100644 --- a/js/src/Ice/UUID.js +++ b/js/src/Ice/UUID.js @@ -4,7 +4,7 @@ export function generateUUID() { let d = new Date().getTime(); - const uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { + const uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => { const r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == "x" ? r : (r & 0x3) | 0x8).toString(16); diff --git a/js/src/Ice/Value.js b/js/src/Ice/Value.js index 59409c011d4..6320d1f596c 100644 --- a/js/src/Ice/Value.js +++ b/js/src/Ice/Value.js @@ -42,7 +42,7 @@ export class Value { static read(is) { const v = { value: null }; - is.readValue((o) => { + is.readValue(o => { v.value = o; }, this); return v; diff --git a/js/src/Ice/WSTransceiver.js b/js/src/Ice/WSTransceiver.js index 0cecc992c32..b82ede3b858 100644 --- a/js/src/Ice/WSTransceiver.js +++ b/js/src/Ice/WSTransceiver.js @@ -60,9 +60,9 @@ if (typeof WebSocket !== "undefined") { this._state = StateConnectPending; this._fd = new WebSocket(this._url, "ice.zeroc.com"); this._fd.binaryType = "arraybuffer"; - this._fd.onopen = (e) => this.socketConnected(e); - this._fd.onmessage = (e) => this.socketBytesAvailable(e.data); - this._fd.onclose = (e) => this.socketClosed(e); + this._fd.onopen = e => this.socketConnected(e); + this._fd.onmessage = e => this.socketBytesAvailable(e.data); + this._fd.onclose = e => this.socketClosed(e); return SocketOperation.Connect; // Waiting for connect to complete. } else if (this._state === StateConnectPending) { // diff --git a/js/test/Common/ControllerWorker.js b/js/test/Common/ControllerWorker.js index 2d4611546fc..64214dab2ba 100644 --- a/js/test/Common/ControllerWorker.js +++ b/js/test/Common/ControllerWorker.js @@ -16,7 +16,7 @@ class Output { } } -self.onmessage = async (e) => { +self.onmessage = async e => { try { const helper = new ControllerHelper(e.data.exe, Output);