mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-07 16:25:45 +01:00
Replace Array.slice conversions of the arguments object with rest parameters.
This commit is contained in:
@@ -488,9 +488,9 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
|
||||
init.supercall(this);
|
||||
},
|
||||
|
||||
complete: function CPM_complete(context) {
|
||||
complete: function CPM_complete(context, ...args) {
|
||||
if (this.completer)
|
||||
context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1));
|
||||
context.forkapply("prompt", 0, this, "completer", args);
|
||||
},
|
||||
|
||||
get mode() modes.PROMPT
|
||||
@@ -955,7 +955,7 @@ var CommandLine = Module("commandline", {
|
||||
|
||||
updateOutputHeight: deprecated("mow.resize", function updateOutputHeight(open, extra) mow.resize(open, extra)),
|
||||
|
||||
withOutputToString: function withOutputToString(fn, self) {
|
||||
withOutputToString: function withOutputToString(fn, self, ...args) {
|
||||
dactyl.registerObserver("echoLine", observe, true);
|
||||
dactyl.registerObserver("echoMultiline", observe, true);
|
||||
|
||||
@@ -965,7 +965,7 @@ var CommandLine = Module("commandline", {
|
||||
}
|
||||
|
||||
this.savingOutput = true;
|
||||
dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2)));
|
||||
dactyl.trapErrors.apply(dactyl, [fn, self].concat(args));
|
||||
this.savingOutput = false;
|
||||
return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem)
|
||||
.join("\n");
|
||||
@@ -1764,8 +1764,7 @@ var CommandLine = Module("commandline", {
|
||||
return Events.PASS;
|
||||
});
|
||||
|
||||
let bind = function bind()
|
||||
mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments)));
|
||||
let bind = function bind(...args) mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(args));
|
||||
|
||||
bind(["<Esc>", "<C-[>"], "Stop waiting for completions or exit Command Line mode",
|
||||
function ({ self }) {
|
||||
|
||||
@@ -235,8 +235,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
});
|
||||
},
|
||||
|
||||
triggerObserver: function triggerObserver(type) {
|
||||
return this.applyTriggerObserver(type, Array.slice(arguments, 1));
|
||||
triggerObserver: function triggerObserver(type, ...args) {
|
||||
return this.applyTriggerObserver(type, args);
|
||||
},
|
||||
|
||||
addUsageCommand: function (params) {
|
||||
@@ -523,10 +523,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* Acts like the Function builtin, but the code executes in the
|
||||
* userContext global.
|
||||
*/
|
||||
userFunc: function userFunc() {
|
||||
userFunc: function userFunc(...args) {
|
||||
return this.userEval(
|
||||
"(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" +
|
||||
" { " + arguments[arguments.length - 1] + " })");
|
||||
"(function userFunction(" + args.slice(0, -1).join(", ") + ")" +
|
||||
" { " + args.pop() + " })");
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1116,11 +1116,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* @param {function} func The function to call
|
||||
* @param {object} self The 'this' object for the function.
|
||||
*/
|
||||
trapErrors: function trapErrors(func, self) {
|
||||
trapErrors: function trapErrors(func, self, ...args) {
|
||||
try {
|
||||
if (isString(func))
|
||||
func = self[func];
|
||||
return func.apply(self || this, Array.slice(arguments, 2));
|
||||
return func.apply(self || this, args);
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
|
||||
@@ -1324,8 +1324,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
},
|
||||
{ count: true });
|
||||
|
||||
let bind = function bind() mappings.add.apply(mappings,
|
||||
[[modes.AUTOCOMPLETE]].concat(Array.slice(arguments)));
|
||||
let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args));
|
||||
|
||||
bind(["<Esc>"], "Return to Insert mode",
|
||||
function () Events.PASS_THROUGH);
|
||||
|
||||
@@ -352,7 +352,7 @@ var History = Module("history", {
|
||||
completion.addUrlCompleter("history", "History", completion.history);
|
||||
},
|
||||
mappings: function initMappings() {
|
||||
function bind() mappings.add.apply(mappings, [config.browserModes].concat(Array.slice(arguments)));
|
||||
function bind(...args) mappings.add.apply(mappings, [config.browserModes].concat(args));
|
||||
|
||||
bind(["<C-o>"], "Go to an older position in the jump list",
|
||||
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },
|
||||
|
||||
Reference in New Issue
Block a user