Commit 8e6307e8 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Remove unnecessary `Array.from(...)`

As pointed by @robertknight `Array.from` was probably a leftover from
the tool that was used to convert CoffeeScript to JavaScript.
parent 946eda90
...@@ -24,7 +24,7 @@ export default class Bridge { ...@@ -24,7 +24,7 @@ export default class Bridge {
* This removes the event listeners for messages arriving from other windows. * This removes the event listeners for messages arriving from other windows.
*/ */
destroy() { destroy() {
Array.from(this.links).map(link => link.channel.destroy()); this.links.map(link => link.channel.destroy());
} }
/** /**
...@@ -47,9 +47,7 @@ export default class Bridge { ...@@ -47,9 +47,7 @@ export default class Bridge {
return; return;
} }
connected = true; connected = true;
Array.from(this.onConnectListeners).forEach(cb => this.onConnectListeners.forEach(cb => cb.call(null, channel, source));
cb.call(null, channel, source)
);
}; };
const connect = (_token, cb) => { const connect = (_token, cb) => {
...@@ -100,9 +98,7 @@ export default class Bridge { ...@@ -100,9 +98,7 @@ export default class Bridge {
const _makeDestroyFn = c => { const _makeDestroyFn = c => {
return error => { return error => {
c.destroy(); c.destroy();
this.links = Array.from(this.links) this.links = this.links.filter(l => l.channel !== c);
.filter(l => l.channel !== c)
.map(l => l);
throw error; throw error;
}; };
}; };
...@@ -111,7 +107,7 @@ export default class Bridge { ...@@ -111,7 +107,7 @@ export default class Bridge {
const p = new Promise((resolve, reject) => { const p = new Promise((resolve, reject) => {
const timeout = setTimeout(() => resolve(null), 1000); const timeout = setTimeout(() => resolve(null), 1000);
try { try {
return l.channel.call(method, ...Array.from(args), (err, result) => { return l.channel.call(method, ...args, (err, result) => {
clearTimeout(timeout); clearTimeout(timeout);
if (err) { if (err) {
return reject(err); return reject(err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment