Merge pull request #4872 from atom/destructured-assignment
Destructuring assignment
This commit is contained in:
commit
6041c7edf9
8 changed files with 55 additions and 66 deletions
|
@ -43,9 +43,9 @@ var checkAppInitialized = function() {
|
|||
|
||||
module.exports = {
|
||||
showOpenDialog: function(...args) {
|
||||
var callback, options, prop, properties, ref1, value, window, wrappedCallback;
|
||||
var prop, properties, value, wrappedCallback;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
let [window, options, callback] = parseArgs.apply(null, args);
|
||||
if (options == null) {
|
||||
options = {
|
||||
title: 'Open',
|
||||
|
@ -81,9 +81,9 @@ module.exports = {
|
|||
},
|
||||
|
||||
showSaveDialog: function(...args) {
|
||||
var callback, options, ref1, window, wrappedCallback;
|
||||
var wrappedCallback;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
let [window, options, callback] = parseArgs.apply(null, args);
|
||||
if (options == null) {
|
||||
options = {
|
||||
title: 'Save'
|
||||
|
@ -105,9 +105,9 @@ module.exports = {
|
|||
},
|
||||
|
||||
showMessageBox: function(...args) {
|
||||
var callback, flags, i, j, len, messageBoxType, options, ref1, ref2, ref3, text, window;
|
||||
var flags, i, j, len, messageBoxType, ref2, ref3, text;
|
||||
checkAppInitialized();
|
||||
ref1 = parseArgs.apply(null, args), window = ref1[0], options = ref1[1], callback = ref1[2];
|
||||
let [window, options, callback] = parseArgs.apply(null, args);
|
||||
if (options == null) {
|
||||
options = {
|
||||
type: 'none'
|
||||
|
|
|
@ -51,11 +51,11 @@ var indexOfItemById = function(items, id) {
|
|||
|
||||
// Returns the index of where to insert the item according to |position|.
|
||||
var indexToInsertByPosition = function(items, position) {
|
||||
var id, insertIndex, query, ref1;
|
||||
var insertIndex;
|
||||
if (!position) {
|
||||
return items.length;
|
||||
}
|
||||
ref1 = position.split('='), query = ref1[0], id = ref1[1];
|
||||
const [query, id] = position.split('=');
|
||||
insertIndex = indexOfItemById(items, id);
|
||||
if (insertIndex === -1 && query !== 'endof') {
|
||||
console.warn("Item with id '" + id + "' is not found");
|
||||
|
|
|
@ -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() {
|
||||
|
@ -125,20 +124,16 @@ 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)));
|
||||
webContents.on('ipc-message', function(event, [channel, ...args]) {
|
||||
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) : [];
|
||||
webContents.on('ipc-message-sync', function(event, [channel, ...args]) {
|
||||
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.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const ipcMain = require('electron').ipcMain;
|
||||
const desktopCapturer = process.atomBinding('desktop_capturer').desktopCapturer;
|
||||
|
||||
|
@ -33,7 +35,7 @@ ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function(event, captureW
|
|||
|
||||
desktopCapturer.emit = function(event, name, sources) {
|
||||
// Receiving sources result from main process, now send them back to renderer.
|
||||
var captureScreen, captureWindow, handledRequest, i, len, ref, ref1, ref2, request, result, source, thumbnailSize, unhandledRequestsQueue;
|
||||
var handledRequest, i, len, ref, ref1, request, result, source, unhandledRequestsQueue;
|
||||
handledRequest = requestsQueue.shift(0);
|
||||
result = (function() {
|
||||
var i, len, results;
|
||||
|
@ -69,7 +71,7 @@ desktopCapturer.emit = function(event, name, sources) {
|
|||
|
||||
// If the requestsQueue is not empty, start a new request handling.
|
||||
if (requestsQueue.length > 0) {
|
||||
ref2 = requestsQueue[0].options, captureWindow = ref2.captureWindow, captureScreen = ref2.captureScreen, thumbnailSize = ref2.thumbnailSize;
|
||||
const {captureWindow, captureScreen, thumbnailSize} = requestsQueue[0].options;
|
||||
return desktopCapturer.startHandling(captureWindow, captureScreen, thumbnailSize);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -148,10 +146,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)));
|
||||
guest.on('ipc-message-host', function(_, [channel, ...args]) {
|
||||
return embedder.send.apply(embedder, ["ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + guest.viewInstanceId, channel].concat(args));
|
||||
});
|
||||
|
||||
// Autosize.
|
||||
|
|
|
@ -82,9 +82,7 @@ var createGuest = function(embedder, url, frameName, options) {
|
|||
};
|
||||
|
||||
// Routed window.open messages.
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function(event, ...args) {
|
||||
var frameName, options, url;
|
||||
url = args[0], frameName = args[1], options = args[2];
|
||||
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function(event, url, frameName, options) {
|
||||
options = mergeBrowserWindowOptions(event.sender, options);
|
||||
event.sender.emit('new-window', event, url, frameName, 'new-window', options);
|
||||
if ((event.sender.isGuest() && !event.sender.allowPopups) || event.defaultPrevented) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ let metaToValue = function(meta) {
|
|||
|
||||
// Construct a plain object from the meta.
|
||||
var metaToPlainObject = function(meta) {
|
||||
var i, len, name, obj, ref1, ref2, value;
|
||||
var i, len, obj, ref1;
|
||||
obj = (function() {
|
||||
switch (meta.type) {
|
||||
case 'error':
|
||||
|
@ -227,7 +227,7 @@ var metaToPlainObject = function(meta) {
|
|||
})();
|
||||
ref1 = meta.members;
|
||||
for (i = 0, len = ref1.length; i < len; i++) {
|
||||
ref2 = ref1[i], name = ref2.name, value = ref2.value;
|
||||
let {name, value} = ref1[i];
|
||||
obj[name] = value;
|
||||
}
|
||||
return obj;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue