mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 21:32:25 +01:00
Replace Array.slice conversions of the arguments object with rest parameters.
This commit is contained in:
4
common/bootstrap.js
vendored
4
common/bootstrap.js
vendored
@@ -37,9 +37,9 @@ function reportError(e) {
|
|||||||
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
|
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
|
||||||
.logStringMessage(stack);
|
.logStringMessage(stack);
|
||||||
}
|
}
|
||||||
function debug() {
|
function debug(...args) {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
dump(name + ": " + Array.join(arguments, ", ") + "\n");
|
dump(name + ": " + args.join(", ") + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function httpGet(uri) {
|
function httpGet(uri) {
|
||||||
|
|||||||
@@ -488,9 +488,9 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
|
|||||||
init.supercall(this);
|
init.supercall(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
complete: function CPM_complete(context) {
|
complete: function CPM_complete(context, ...args) {
|
||||||
if (this.completer)
|
if (this.completer)
|
||||||
context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1));
|
context.forkapply("prompt", 0, this, "completer", args);
|
||||||
},
|
},
|
||||||
|
|
||||||
get mode() modes.PROMPT
|
get mode() modes.PROMPT
|
||||||
@@ -955,7 +955,7 @@ var CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
updateOutputHeight: deprecated("mow.resize", function updateOutputHeight(open, extra) mow.resize(open, extra)),
|
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("echoLine", observe, true);
|
||||||
dactyl.registerObserver("echoMultiline", observe, true);
|
dactyl.registerObserver("echoMultiline", observe, true);
|
||||||
|
|
||||||
@@ -965,7 +965,7 @@ var CommandLine = Module("commandline", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.savingOutput = true;
|
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;
|
this.savingOutput = false;
|
||||||
return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem)
|
return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
@@ -1764,8 +1764,7 @@ var CommandLine = Module("commandline", {
|
|||||||
return Events.PASS;
|
return Events.PASS;
|
||||||
});
|
});
|
||||||
|
|
||||||
let bind = function bind()
|
let bind = function bind(...args) mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(args));
|
||||||
mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments)));
|
|
||||||
|
|
||||||
bind(["<Esc>", "<C-[>"], "Stop waiting for completions or exit Command Line mode",
|
bind(["<Esc>", "<C-[>"], "Stop waiting for completions or exit Command Line mode",
|
||||||
function ({ self }) {
|
function ({ self }) {
|
||||||
|
|||||||
@@ -235,8 +235,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerObserver: function triggerObserver(type) {
|
triggerObserver: function triggerObserver(type, ...args) {
|
||||||
return this.applyTriggerObserver(type, Array.slice(arguments, 1));
|
return this.applyTriggerObserver(type, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
addUsageCommand: function (params) {
|
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
|
* Acts like the Function builtin, but the code executes in the
|
||||||
* userContext global.
|
* userContext global.
|
||||||
*/
|
*/
|
||||||
userFunc: function userFunc() {
|
userFunc: function userFunc(...args) {
|
||||||
return this.userEval(
|
return this.userEval(
|
||||||
"(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" +
|
"(function userFunction(" + args.slice(0, -1).join(", ") + ")" +
|
||||||
" { " + arguments[arguments.length - 1] + " })");
|
" { " + args.pop() + " })");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1116,11 +1116,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {function} func The function to call
|
* @param {function} func The function to call
|
||||||
* @param {object} self The 'this' object for the function.
|
* @param {object} self The 'this' object for the function.
|
||||||
*/
|
*/
|
||||||
trapErrors: function trapErrors(func, self) {
|
trapErrors: function trapErrors(func, self, ...args) {
|
||||||
try {
|
try {
|
||||||
if (isString(func))
|
if (isString(func))
|
||||||
func = self[func];
|
func = self[func];
|
||||||
return func.apply(self || this, Array.slice(arguments, 2));
|
return func.apply(self || this, args);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1324,8 +1324,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
|||||||
},
|
},
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
let bind = function bind() mappings.add.apply(mappings,
|
let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args));
|
||||||
[[modes.AUTOCOMPLETE]].concat(Array.slice(arguments)));
|
|
||||||
|
|
||||||
bind(["<Esc>"], "Return to Insert mode",
|
bind(["<Esc>"], "Return to Insert mode",
|
||||||
function () Events.PASS_THROUGH);
|
function () Events.PASS_THROUGH);
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ var History = Module("history", {
|
|||||||
completion.addUrlCompleter("history", "History", completion.history);
|
completion.addUrlCompleter("history", "History", completion.history);
|
||||||
},
|
},
|
||||||
mappings: function initMappings() {
|
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",
|
bind(["<C-o>"], "Go to an older position in the jump list",
|
||||||
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },
|
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ defineModule("addons", {
|
|||||||
this.lazyRequire("completion", ["completion"]);
|
this.lazyRequire("completion", ["completion"]);
|
||||||
lazyRequire("template", ["template"]);
|
lazyRequire("template", ["template"]);
|
||||||
|
|
||||||
var callResult = function callResult(method) {
|
var callResult = function callResult(method, ...args) {
|
||||||
let args = Array.slice(arguments, 1);
|
|
||||||
return function (result) { result[method].apply(result, args); };
|
return function (result) { result[method].apply(result, args); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ Object.defineProperty(defineModule.loadLog, "push", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
defineModule.prefix = "";
|
defineModule.prefix = "";
|
||||||
defineModule.dump = function dump_() {
|
defineModule.dump = function dump_(...args) {
|
||||||
let msg = Array.map(arguments, function (msg) {
|
let msg = args.map(function (msg) {
|
||||||
if (loaded.util && typeof msg == "object")
|
if (loaded.util && typeof msg == "object")
|
||||||
msg = util.objectToString(msg);
|
msg = util.objectToString(msg);
|
||||||
return msg;
|
return msg;
|
||||||
@@ -78,13 +78,13 @@ defineModule.dump = function dump_() {
|
|||||||
.replace(/^./gm, JSMLoader.name + ": $&"));
|
.replace(/^./gm, JSMLoader.name + ": $&"));
|
||||||
}
|
}
|
||||||
defineModule.modules = [];
|
defineModule.modules = [];
|
||||||
defineModule.time = function time(major, minor, func, self) {
|
defineModule.time = function time(major, minor, func, self, ...args) {
|
||||||
let time = Date.now();
|
let time = Date.now();
|
||||||
if (typeof func !== "function")
|
if (typeof func !== "function")
|
||||||
func = self[func];
|
func = self[func];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var res = func.apply(self, Array.slice(arguments, 4));
|
var res = func.apply(self, args);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
loaded.util && util.reportError(e);
|
loaded.util && util.reportError(e);
|
||||||
@@ -441,18 +441,18 @@ function curry(fn, length, self, acc) {
|
|||||||
return fn;
|
return fn;
|
||||||
|
|
||||||
// Close over function with 'this'
|
// Close over function with 'this'
|
||||||
function close(self, fn) function () fn.apply(self, Array.slice(arguments));
|
function close(self, fn) function () fn.apply(self, arguments);
|
||||||
|
|
||||||
if (acc == null)
|
if (acc == null)
|
||||||
acc = [];
|
acc = [];
|
||||||
|
|
||||||
return function curried() {
|
return function curried(...args) {
|
||||||
let args = acc.concat(Array.slice(arguments));
|
|
||||||
|
|
||||||
// The curried result should preserve 'this'
|
// The curried result should preserve 'this'
|
||||||
if (arguments.length == 0)
|
if (args.length == 0)
|
||||||
return close(self || this, curried);
|
return close(self || this, curried);
|
||||||
|
|
||||||
|
let args = acc.concat(args);
|
||||||
|
|
||||||
if (args.length >= length)
|
if (args.length >= length)
|
||||||
return fn.apply(self || this, args);
|
return fn.apply(self || this, args);
|
||||||
|
|
||||||
@@ -461,15 +461,14 @@ function curry(fn, length, self, acc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curry.bind)
|
if (curry.bind)
|
||||||
var bind = function bind(meth, self) let (func = callable(meth) ? meth : self[meth])
|
var bind = function bind(meth, self, ...args) let (func = callable(meth) ? meth : self[meth])
|
||||||
func.bind.apply(func, Array.slice(arguments, 1));
|
func.bind.apply(func, [self].concat(args));
|
||||||
else
|
else
|
||||||
var bind = function bind(func, self) {
|
var bind = function bind(func, self, ...args) {
|
||||||
if (!callable(func))
|
if (!callable(func))
|
||||||
func = self[func];
|
func = self[func];
|
||||||
|
|
||||||
let args = Array.slice(arguments, bind.length);
|
return function bound(...args2) func.apply(self, args.concat(args2));
|
||||||
return function bound() func.apply(self, args.concat(Array.slice(arguments)));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -574,8 +573,8 @@ function isString(val) objproto.toString.call(val) == "[object String]";
|
|||||||
*/
|
*/
|
||||||
function callable(val) typeof val === "function" && !(val instanceof Ci.nsIDOMElement);
|
function callable(val) typeof val === "function" && !(val instanceof Ci.nsIDOMElement);
|
||||||
|
|
||||||
function call(fn) {
|
function call(fn, self, ...args) {
|
||||||
fn.apply(arguments[1], Array.slice(arguments, 2));
|
fn.apply(self, args);
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,8 +659,8 @@ function update(target) {
|
|||||||
func.superapply = function superapply(self, args)
|
func.superapply = function superapply(self, args)
|
||||||
let (meth = Object.getPrototypeOf(target)[k])
|
let (meth = Object.getPrototypeOf(target)[k])
|
||||||
meth && meth.apply(self, args);
|
meth && meth.apply(self, args);
|
||||||
func.supercall = function supercall(self)
|
func.supercall = function supercall(self, ...args)
|
||||||
func.superapply(self, Array.slice(arguments, 1));
|
func.superapply(self, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.defineProperty(target, k, desc);
|
Object.defineProperty(target, k, desc);
|
||||||
@@ -687,8 +686,8 @@ function update_(target) {
|
|||||||
func.superapply = function super_apply(self, args)
|
func.superapply = function super_apply(self, args)
|
||||||
let (meth = Object.getPrototypeOf(target)[k])
|
let (meth = Object.getPrototypeOf(target)[k])
|
||||||
meth && meth.apply(self, args);
|
meth && meth.apply(self, args);
|
||||||
func.supercall = function super_call(self)
|
func.supercall = function super_call(self, ...args)
|
||||||
func.superapply(self, Array.slice(arguments, 1));
|
func.superapply(self, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.defineProperty(target, k, desc);
|
Object.defineProperty(target, k, desc);
|
||||||
@@ -722,9 +721,8 @@ function update_(target) {
|
|||||||
*
|
*
|
||||||
* @returns {function} The constructor for the resulting class.
|
* @returns {function} The constructor for the resulting class.
|
||||||
*/
|
*/
|
||||||
function Class() {
|
function Class(...args) {
|
||||||
|
|
||||||
var args = Array.slice(arguments);
|
|
||||||
if (isString(args[0]))
|
if (isString(args[0]))
|
||||||
var name = args.shift();
|
var name = args.shift();
|
||||||
var superclass = Class;
|
var superclass = Class;
|
||||||
@@ -991,8 +989,8 @@ Class.prototype = {
|
|||||||
return meth && meth.apply(self, args);
|
return meth && meth.apply(self, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
func.supercall = function supercall(self) {
|
func.supercall = function supercall(self, ...args) {
|
||||||
return func.superapply(self, Array.slice(arguments, 1));
|
return func.superapply(self, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1129,22 +1127,22 @@ var Finished = Class("Finished", ErrorBase);
|
|||||||
* @param {Object} classProperties Properties to be applied to the class constructor.
|
* @param {Object} classProperties Properties to be applied to the class constructor.
|
||||||
* @returns {Class}
|
* @returns {Class}
|
||||||
*/
|
*/
|
||||||
function Module(name, prototype) {
|
function Module(name, prototype, ...args) {
|
||||||
try {
|
try {
|
||||||
let init = callable(prototype) ? 4 : 3;
|
let init = callable(prototype) ? 2 : 1;
|
||||||
let proto = arguments[callable(prototype) ? 2 : 1];
|
let proto = callable(prototype) ? args[0] : prototype;
|
||||||
|
|
||||||
proto._metaInit_ = function () {
|
proto._metaInit_ = function () {
|
||||||
delete module.prototype._metaInit_;
|
delete module.prototype._metaInit_;
|
||||||
currentModule[name.toLowerCase()] = this;
|
currentModule[name.toLowerCase()] = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
const module = Class.apply(Class, Array.slice(arguments, 0, init));
|
const module = Class.apply(Class, [name, prototype, ...args.slice(0, init)]);
|
||||||
let instance = module();
|
let instance = module();
|
||||||
module.className = name.toLowerCase();
|
module.className = name.toLowerCase();
|
||||||
|
|
||||||
instance.INIT = update(Object.create(Module.INIT),
|
instance.INIT = update(Object.create(Module.INIT),
|
||||||
arguments[init] || {});
|
args[init] || {});
|
||||||
|
|
||||||
currentModule[module.className] = instance;
|
currentModule[module.className] = instance;
|
||||||
defineModule.modules.push(instance);
|
defineModule.modules.push(instance);
|
||||||
@@ -1201,13 +1199,9 @@ Module.INIT = {
|
|||||||
*
|
*
|
||||||
* @returns {function} The constructor for the new Struct.
|
* @returns {function} The constructor for the new Struct.
|
||||||
*/
|
*/
|
||||||
function Struct() {
|
function Struct(...args) {
|
||||||
if (!/^[A-Z]/.test(arguments[0]))
|
if (/^[A-Z]/.test(args[0]))
|
||||||
var args = Array.slice(arguments, 0);
|
var className = args.shift();
|
||||||
else {
|
|
||||||
var className = arguments[0];
|
|
||||||
args = Array.slice(arguments, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Struct = Class(className || "Struct", StructBase, {
|
const Struct = Class(className || "Struct", StructBase, {
|
||||||
length: args.length,
|
length: args.length,
|
||||||
@@ -1601,9 +1595,9 @@ var array = Class("array", Array, {
|
|||||||
},
|
},
|
||||||
array: ary,
|
array: ary,
|
||||||
toString: function () this.array.toString(),
|
toString: function () this.array.toString(),
|
||||||
concat: function () this.__noSuchMethod__("concat", Array.slice(arguments)),
|
concat: function (...args) this.__noSuchMethod__("concat", args),
|
||||||
filter: function () this.__noSuchMethod__("filter", Array.slice(arguments)),
|
filter: function (...args) this.__noSuchMethod__("filter", args),
|
||||||
map: function () this.__noSuchMethod__("map", Array.slice(arguments))
|
map: function (...args) this.__noSuchMethod__("map", args)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@@ -1736,8 +1730,8 @@ var array = Class("array", Array, {
|
|||||||
/* Make Minefield not explode, because Minefield exploding is not fun. */
|
/* Make Minefield not explode, because Minefield exploding is not fun. */
|
||||||
let iterProto = Iter.prototype;
|
let iterProto = Iter.prototype;
|
||||||
Object.keys(iter).forEach(function (k) {
|
Object.keys(iter).forEach(function (k) {
|
||||||
iterProto[k] = function () {
|
iterProto[k] = function (...args) {
|
||||||
let res = iter[k].apply(iter, [this].concat(Array.slice(arguments)));
|
let res = iter[k].apply(iter, [this].concat(args));
|
||||||
if (isinstance(res, ["Iterator", "Generator"]))
|
if (isinstance(res, ["Iterator", "Generator"]))
|
||||||
return Iter(res);
|
return Iter(res);
|
||||||
return res;
|
return res;
|
||||||
@@ -1746,8 +1740,8 @@ Object.keys(iter).forEach(function (k) {
|
|||||||
|
|
||||||
Object.keys(array).forEach(function (k) {
|
Object.keys(array).forEach(function (k) {
|
||||||
if (!(k in iterProto))
|
if (!(k in iterProto))
|
||||||
iterProto[k] = function () {
|
iterProto[k] = function (...args) {
|
||||||
let res = array[k].apply(array, [this.toArray()].concat(Array.slice(arguments)));
|
let res = array[k].apply(array, [this.toArray()].concat(args));
|
||||||
if (isinstance(res, ["Iterator", "Generator"]))
|
if (isinstance(res, ["Iterator", "Generator"]))
|
||||||
return Iter(res);
|
return Iter(res);
|
||||||
if (isArray(res))
|
if (isArray(res))
|
||||||
|
|||||||
@@ -1571,7 +1571,7 @@ var Commands = Module("commands", {
|
|||||||
return dactyl.userEval(completer);
|
return dactyl.userEval(completer);
|
||||||
});
|
});
|
||||||
if (callable(result))
|
if (callable(result))
|
||||||
return result.apply(this, Array.slice(arguments));
|
return result.apply(this, arguments);
|
||||||
else
|
else
|
||||||
return context.completions = result;
|
return context.completions = result;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -705,8 +705,8 @@ var CompletionContext = Class("CompletionContext", {
|
|||||||
* for the new context. If a string is provided, it is
|
* for the new context. If a string is provided, it is
|
||||||
* interpreted as a method to access on *self*.
|
* interpreted as a method to access on *self*.
|
||||||
*/
|
*/
|
||||||
fork: function fork(name, offset, self, completer) {
|
fork: function fork(name, offset, self, completer, ...args) {
|
||||||
return this.forkapply(name, offset, self, completer, Array.slice(arguments, fork.length));
|
return this.forkapply(name, offset, self, completer, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
forkapply: function forkapply(name, offset, self, completer, args) {
|
forkapply: function forkapply(name, offset, self, completer, args) {
|
||||||
@@ -731,7 +731,7 @@ var CompletionContext = Class("CompletionContext", {
|
|||||||
return context;
|
return context;
|
||||||
},
|
},
|
||||||
|
|
||||||
split: function split(name, obj, fn) {
|
split: function split(name, obj, fn, ...args) {
|
||||||
let context = this.fork(name);
|
let context = this.fork(name);
|
||||||
let alias = (prop) => {
|
let alias = (prop) => {
|
||||||
context.__defineGetter__(prop, () => this[prop]);
|
context.__defineGetter__(prop, () => this[prop]);
|
||||||
@@ -746,7 +746,7 @@ var CompletionContext = Class("CompletionContext", {
|
|||||||
context.hasItems = true;
|
context.hasItems = true;
|
||||||
this.hasItems = false;
|
this.hasItems = false;
|
||||||
if (fn)
|
if (fn)
|
||||||
return fn.apply(obj || this, [context].concat(Array.slice(arguments, split.length)));
|
return fn.apply(obj || this, [context].concat(args));
|
||||||
return context;
|
return context;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -903,10 +903,10 @@ var Completion = Module("completion", {
|
|||||||
get options() modules.options,
|
get options() modules.options,
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
_runCompleter: function _runCompleter(name, filter, maxItems) {
|
_runCompleter: function _runCompleter(name, filter, maxItems, ...args) {
|
||||||
let context = modules.CompletionContext(filter);
|
let context = modules.CompletionContext(filter);
|
||||||
context.maxItems = maxItems;
|
context.maxItems = maxItems;
|
||||||
let res = context.fork.apply(context, ["run", 0, this, name].concat(Array.slice(arguments, 3)));
|
let res = context.fork.apply(context, ["run", 0, this, name].concat(args));
|
||||||
if (res) {
|
if (res) {
|
||||||
if (Components.stack.caller.name === "runCompleter") // FIXME
|
if (Components.stack.caller.name === "runCompleter") // FIXME
|
||||||
return { items: res.map(function m(i) ({ item: i })) };
|
return { items: res.map(function m(i) ({ item: i })) };
|
||||||
@@ -917,14 +917,14 @@ var Completion = Module("completion", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
runCompleter: function runCompleter(name, filter, maxItems) {
|
runCompleter: function runCompleter(name, filter, maxItems) {
|
||||||
return this._runCompleter.apply(this, Array.slice(arguments))
|
return this._runCompleter.apply(this, arguments)
|
||||||
.items.map(function m(i) i.item);
|
.items.map(function m(i) i.item);
|
||||||
},
|
},
|
||||||
|
|
||||||
listCompleter: function listCompleter(name, filter, maxItems) {
|
listCompleter: function listCompleter(name, filter, maxItems, ...args) {
|
||||||
let context = modules.CompletionContext(filter || "");
|
let context = modules.CompletionContext(filter || "");
|
||||||
context.maxItems = maxItems;
|
context.maxItems = maxItems;
|
||||||
context.fork.apply(context, ["list", 0, this, name].concat(Array.slice(arguments, 3)));
|
context.fork.apply(context, ["list", 0, this, name].concat(args));
|
||||||
context = context.contexts["/list"];
|
context = context.contexts["/list"];
|
||||||
context.wait(null, true);
|
context.wait(null, true);
|
||||||
|
|
||||||
@@ -987,9 +987,9 @@ var Completion = Module("completion", {
|
|||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
addUrlCompleter: function addUrlCompleter(opt) {
|
addUrlCompleter: function addUrlCompleter(opt, ...args) {
|
||||||
let completer = Completion.UrlCompleter.apply(null, Array.slice(arguments));
|
let completer = Completion.UrlCompleter.apply(null, [opt, ...args]);
|
||||||
completer.args = Array.slice(arguments, completer.length);
|
completer.args = args;
|
||||||
this.urlCompleters[opt] = completer;
|
this.urlCompleters[opt] = completer;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ var Group = Class("Group", {
|
|||||||
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
|
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
compileFilter: function (patterns, default_) {
|
compileFilter: function (patterns, default_ = false) {
|
||||||
if (arguments.length < 2)
|
if (arguments.length < 2)
|
||||||
default_ = false;
|
default_ = false;
|
||||||
|
|
||||||
|
|||||||
@@ -855,8 +855,7 @@ var JavaScript = Module("javascript", {
|
|||||||
mappings: function initMappings(dactyl, modules, window) {
|
mappings: function initMappings(dactyl, modules, window) {
|
||||||
const { mappings, modes } = modules;
|
const { mappings, modes } = modules;
|
||||||
|
|
||||||
function bind() mappings.add.apply(mappings,
|
function bind(...args) mappings.add.apply(mappings, [[modes.REPL]].concat(args))
|
||||||
[[modes.REPL]].concat(Array.slice(arguments)))
|
|
||||||
|
|
||||||
bind(["<Return>"], "Accept the current input",
|
bind(["<Return>"], "Accept the current input",
|
||||||
function ({ self }) { self.accept(); });
|
function ({ self }) { self.accept(); });
|
||||||
|
|||||||
@@ -65,14 +65,13 @@ var Modules = function Modules(window) {
|
|||||||
*
|
*
|
||||||
* @returns {function} The constructor for the resulting module.
|
* @returns {function} The constructor for the resulting module.
|
||||||
*/
|
*/
|
||||||
function Module(name) {
|
function Module(name, ...args) {
|
||||||
let args = Array.slice(arguments);
|
|
||||||
|
|
||||||
var base = ModuleBase;
|
var base = ModuleBase;
|
||||||
if (callable(args[1]))
|
if (callable(args[0]))
|
||||||
base = args.splice(1, 1)[0];
|
base = args.shift();
|
||||||
|
|
||||||
let [, prototype, classProperties, moduleInit] = args;
|
let [prototype, classProperties, moduleInit] = args;
|
||||||
prototype._metaInit_ = function () {
|
prototype._metaInit_ = function () {
|
||||||
delete module.prototype._metaInit_;
|
delete module.prototype._metaInit_;
|
||||||
Class.replaceProperty(modules, module.className, this);
|
Class.replaceProperty(modules, module.className, this);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ var Messages = Module("messages", {
|
|||||||
file = io.File(file);
|
file = io.File(file);
|
||||||
|
|
||||||
function properties(base, iter_, prop) iter(function _properties() {
|
function properties(base, iter_, prop) iter(function _properties() {
|
||||||
function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[\\:=]/g, "\\$&");
|
function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&");
|
||||||
|
|
||||||
prop = prop || "description";
|
prop = prop || "description";
|
||||||
for (var obj in iter_) {
|
for (var obj in iter_) {
|
||||||
|
|||||||
@@ -1622,11 +1622,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {function} func The function to call
|
* @param {function} func The function to call
|
||||||
* @param {object} self The 'this' object for the function.
|
* @param {object} self The 'this' object for the function.
|
||||||
*/
|
*/
|
||||||
trapErrors: function trapErrors(func, self) {
|
trapErrors: function trapErrors(func, self, ...args) {
|
||||||
try {
|
try {
|
||||||
if (!callable(func))
|
if (!callable(func))
|
||||||
func = self[func];
|
func = self[func];
|
||||||
return func.apply(self || this, Array.slice(arguments, 2));
|
return func.apply(self || this, args);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
this.reportError(e);
|
this.reportError(e);
|
||||||
@@ -1708,9 +1708,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {object} self The 'this' object of the method.
|
* @param {object} self The 'this' object of the method.
|
||||||
* @param ... Arguments to pass to *meth*.
|
* @param ... Arguments to pass to *meth*.
|
||||||
*/
|
*/
|
||||||
withProperErrors: function withProperErrors(meth, self) {
|
withProperErrors: function withProperErrors(meth, self, ...args) {
|
||||||
try {
|
try {
|
||||||
return (callable(meth) ? meth : self[meth]).apply(self, Array.slice(arguments, withProperErrors.length));
|
return (callable(meth) ? meth : self[meth]).apply(self, args);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw e.stack ? e : Error(e);
|
throw e.stack ? e : Error(e);
|
||||||
|
|||||||
@@ -389,10 +389,10 @@ Controller.prototype = {
|
|||||||
* @param {...} Extra arguments are passed to the completion
|
* @param {...} Extra arguments are passed to the completion
|
||||||
* function directly.
|
* function directly.
|
||||||
*/
|
*/
|
||||||
testCompleter: wrapAssertNoErrors(function testCompleter(self, func, string, message) {
|
testCompleter: wrapAssertNoErrors(function testCompleter(self, func, string, message, ...args) {
|
||||||
var context = this.modules.CompletionContext(string || "");
|
var context = this.modules.CompletionContext(string || "");
|
||||||
context.tabPressed = true;
|
context.tabPressed = true;
|
||||||
context.forkapply("completions", 0, self, func, Array.slice(arguments, testCompleter.length));
|
context.forkapply("completions", 0, self, func, args);
|
||||||
|
|
||||||
utils.assert("dactyl.runCompletions", context.wait(5000),
|
utils.assert("dactyl.runCompletions", context.wait(5000),
|
||||||
message || "Completion failed: " + self + "." + func);
|
message || "Completion failed: " + self + "." + func);
|
||||||
|
|||||||
@@ -985,9 +985,9 @@ function _runCommands(cmdName, testName, commands) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function runTest(message, test) {
|
function runTest(message, test, ...args) {
|
||||||
if (test)
|
if (test)
|
||||||
var res = test.apply(null, Array.slice(arguments, runTest.length));
|
var res = test.apply(null, args);
|
||||||
if (res !== undefined)
|
if (res !== undefined)
|
||||||
jumlib.assert(res, message);
|
jumlib.assert(res, message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user