Use destructuring assigment

This commit is contained in:
Kevin Sawicki 2016-03-21 09:39:07 -07:00
parent baa566adae
commit 4f4dc2f4d8
3 changed files with 40 additions and 48 deletions

View file

@ -9,7 +9,6 @@ const Menu = require('electron').Menu;
const binding = process.atomBinding('web_contents');
const debuggerBinding = process.atomBinding('debugger');
let slice = [].slice;
let nextId = 0;
let getNextId = function() {
@ -126,19 +125,17 @@ let wrapWebContents = function(webContents) {
// Dispatch IPC messages to the ipc module.
webContents.on('ipc-message', function(event, packed) {
var args, channel;
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
return ipcMain.emit.apply(ipcMain, [channel, event].concat(slice.call(args)));
const [channel, ...args] = packed;
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args));
});
webContents.on('ipc-message-sync', function(event, packed) {
var args, channel;
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
const [channel, ...args] = packed;
Object.defineProperty(event, 'returnValue', {
set: function(value) {
return event.sendReply(JSON.stringify(value));
}
});
return ipcMain.emit.apply(ipcMain, [channel, event].concat(slice.call(args)));
return ipcMain.emit.apply(ipcMain, [channel, event].concat(args));
});
// Handle context menu action request from pepper plugin.

View file

@ -3,8 +3,6 @@
const ipcMain = require('electron').ipcMain;
const webContents = require('electron').webContents;
var slice = [].slice;
// Doesn't exist in early initialization.
var webViewManager = null;
@ -149,9 +147,8 @@ var createGuest = function(embedder, params) {
// Dispatch guest's IPC messages to embedder.
guest.on('ipc-message-host', function(_, packed) {
var args, channel;
channel = packed[0], args = 2 <= packed.length ? slice.call(packed, 1) : [];
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + guest.viewInstanceId, channel].concat(slice.call(args)));
const [channel, ...args] = packed;
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + guest.viewInstanceId, channel].concat(args));
});
// Autosize.

View file

@ -150,9 +150,9 @@
}
old = module[name];
return module[name] = function() {
var archive, asarPath, filePath, isAsar, newPath, p, ref;
var archive, newPath, p;
p = arguments[arg];
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return old.apply(this, arguments);
}
@ -176,9 +176,9 @@
}
old = module[name];
return module[name] = function() {
var archive, asarPath, callback, filePath, isAsar, newPath, p, ref;
var archive, callback, newPath, p;
p = arguments[arg];
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return old.apply(this, arguments);
}
@ -221,8 +221,8 @@
lstatSync = fs.lstatSync;
fs.lstatSync = function(p) {
var archive, asarPath, filePath, isAsar, ref, stats;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, stats;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return lstatSync(p);
}
@ -238,8 +238,8 @@
};
lstat = fs.lstat;
fs.lstat = function(p, callback) {
var archive, asarPath, filePath, isAsar, ref, stats;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, stats;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return lstat(p, callback);
}
@ -257,7 +257,7 @@
};
statSync = fs.statSync;
fs.statSync = function(p) {
var isAsar = splitPath(p)[0];
const [isAsar] = splitPath(p);
if (!isAsar) {
return statSync(p);
}
@ -267,7 +267,7 @@
};
stat = fs.stat;
fs.stat = function(p, callback) {
var isAsar = splitPath(p)[0];
const [isAsar] = splitPath(p);
if (!isAsar) {
return stat(p, callback);
}
@ -279,8 +279,8 @@
};
statSyncNoException = fs.statSyncNoException;
fs.statSyncNoException = function(p) {
var archive, asarPath, filePath, isAsar, ref, stats;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, stats;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return statSyncNoException(p);
}
@ -296,8 +296,8 @@
};
realpathSync = fs.realpathSync;
fs.realpathSync = function(p) {
var archive, asarPath, filePath, isAsar, real, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, real;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return realpathSync.apply(this, arguments);
}
@ -313,8 +313,8 @@
};
realpath = fs.realpath;
fs.realpath = function(p, cache, callback) {
var archive, asarPath, filePath, isAsar, real, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, real;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return realpath.apply(this, arguments);
}
@ -339,8 +339,8 @@
};
exists = fs.exists;
fs.exists = function(p, callback) {
var archive, asarPath, filePath, isAsar, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return exists(p, callback);
}
@ -354,8 +354,8 @@
};
existsSync = fs.existsSync;
fs.existsSync = function(p) {
var archive, asarPath, filePath, isAsar, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return existsSync(p);
}
@ -367,8 +367,8 @@
};
readFile = fs.readFile;
fs.readFile = function(p, options, callback) {
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, realPath, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, buffer, encoding, fd, info, realPath;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return readFile.apply(this, arguments);
}
@ -418,9 +418,9 @@
readFileSync = fs.readFileSync;
fs.readFileSync = function(p, opts) {
// this allows v8 to optimize this function
var archive, asarPath, buffer, encoding, fd, filePath, info, isAsar, options, realPath, ref;
var archive, buffer, encoding, fd, info, options, realPath;
options = opts;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return readFileSync.apply(this, arguments);
}
@ -470,8 +470,8 @@
};
readdir = fs.readdir;
fs.readdir = function(p, callback) {
var archive, asarPath, filePath, files, isAsar, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, files;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return readdir.apply(this, arguments);
}
@ -489,8 +489,8 @@
};
readdirSync = fs.readdirSync;
fs.readdirSync = function(p) {
var archive, asarPath, filePath, files, isAsar, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, files;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return readdirSync.apply(this, arguments);
}
@ -506,8 +506,8 @@
};
internalModuleReadFile = process.binding('fs').internalModuleReadFile;
process.binding('fs').internalModuleReadFile = function(p) {
var archive, asarPath, buffer, fd, filePath, info, isAsar, realPath, ref;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, buffer, fd, info, realPath;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return internalModuleReadFile(p);
}
@ -539,8 +539,8 @@
};
internalModuleStat = process.binding('fs').internalModuleStat;
process.binding('fs').internalModuleStat = function(p) {
var archive, asarPath, filePath, isAsar, ref, stats;
ref = splitPath(p), isAsar = ref[0], asarPath = ref[1], filePath = ref[2];
var archive, stats;
const [isAsar, asarPath, filePath] = splitPath(p);
if (!isAsar) {
return internalModuleStat(p);
}
@ -570,11 +570,10 @@
if (process.platform === 'win32') {
mkdir = fs.mkdir;
fs.mkdir = function(p, mode, callback) {
var filePath, isAsar, ref;
if (typeof mode === 'function') {
callback = mode;
}
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
const [isAsar, , filePath] = splitPath(p);
if (isAsar && filePath.length) {
return notDirError(callback);
}
@ -582,8 +581,7 @@
};
mkdirSync = fs.mkdirSync;
fs.mkdirSync = function(p, mode) {
var filePath, isAsar, ref;
ref = splitPath(p), isAsar = ref[0], filePath = ref[2];
const [isAsar, , filePath] = splitPath(p);
if (isAsar && filePath.length) {
notDirError();
}