Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use [].concat instead of Array.concat #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/content/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
* @param {[Modes.Mode]} modes The modes for which to return mappings.
*/
iterate: function (modes) {
let stacks = Array.concat(modes).map(this.bound.getStack);
let stacks = [].concat(modes).map(this.bound.getStack);
return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name))
.filter(map => map.rhs &&
stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name))));
Expand All @@ -201,7 +201,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
* @optional
*/
add: function (modes, keys, description, action, extra={}) {
modes = Array.concat(modes);
modes = [].concat(modes);
if (!modes.every(identity))
throw TypeError(/*L*/"Invalid modes: " + modes);

Expand Down Expand Up @@ -746,7 +746,7 @@ var Mappings = Module("mappings", {
names: ["-mode", "-m"],
type: CommandOption.STRING,
validator: function (value) {
return Array.concat(value).every(findMode);
return [].concat(value).every(findMode);
},
completer: function () {
return modes.all.filter(mode => !mode.hidden)
Expand Down
2 changes: 1 addition & 1 deletion common/content/quickmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var QuickMarks = Module("quickmarks", {
let uppercaseMarks = marks.filter(bind("test", /[A-Z]/)).sort();
let numberMarks = marks.filter(bind("test", /[0-9]/)).sort();

marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);
marks = [].concat(lowercaseMarks, uppercaseMarks, numberMarks);

dactyl.assert(marks.length > 0, _("quickmark.none"));

Expand Down
2 changes: 1 addition & 1 deletion common/modules/addons.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ var Addons = Module("addons", {
return (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon));
}

commands.add(Array.concat(command.name),
commands.add([].concat(command.name),
command.description,
function (args) {
let name = args[0];
Expand Down
4 changes: 2 additions & 2 deletions common/modules/base.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ function isinstance(object, interfaces) {
if (object == null)
return false;

return Array.concat(interfaces).some(function isinstance_some(iface) {
return [].concat(interfaces).some(function isinstance_some(iface) {
if (typeof iface === "string") {
if (objToString(object) === "[object " + iface + "]")
return true;
Expand Down Expand Up @@ -1243,7 +1243,7 @@ memoize(Class.prototype, "bound", Class.makeClosure);
* @returns {Class}
*/
function XPCOM(interfaces, superClass) {
interfaces = Array.concat(interfaces);
interfaces = [].concat(interfaces);

let shim = XPCOMShim(interfaces);

Expand Down
4 changes: 2 additions & 2 deletions common/modules/commands.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ update(CommandOption, {
*/
var Command = Class("Command", {
init: function init(specs, description, action, extra) {
specs = Array.concat(specs); // XXX
specs = [].concat(specs); // XXX

this.specs = specs;
this.description = description;
Expand Down Expand Up @@ -992,7 +992,7 @@ var Commands = Module("commands", {
hasDomain: function hasDomain(command, host) {
try {
for (let [cmd, args] of this.subCommands(command))
if (Array.concat(cmd.domains(args)).some(domain => util.isSubdomain(domain, host)))
if ([].concat(cmd.domains(args)).some(domain => util.isSubdomain(domain, host)))
return true;
}
catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion common/modules/completion.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ var CompletionContext = Class("CompletionContext", {
yield ["context", function p_context() { return self; }];
yield ["result", quote ? function p_result() { return quote[0] + util.trapErrors(1, quote, this.text) + quote[2]; }
: function p_result() { return this.text; }];
yield ["texts", function p_texts() { return Array.concat(this.text); }];
yield ["texts", function p_texts() { return [].concat(this.text); }];
};

for (let i of iter(this.keys, result(this.quote))) {
Expand Down
2 changes: 1 addition & 1 deletion common/modules/help.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ var Help = Module("Help", {
flush: function flush(entries, time) {
cache.flushEntry("help.json", time);

for (let entry of Array.concat(entries || []))
for (let entry of [].concat(entries || []))
cache.flushEntry(entry, time);
},

Expand Down
2 changes: 1 addition & 1 deletion common/modules/javascript.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ var JavaScript = Module("javascript", {
* functions.
*/
setCompleter: function (funcs, completers) {
funcs = Array.concat(funcs);
funcs = [].concat(funcs);
for (let func of funcs) {
func.dactylCompleter = function (context, func, obj, args) {
let completer = completers[args.length - 1];
Expand Down
10 changes: 5 additions & 5 deletions common/modules/options.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ var Option = Class("Option", {
},

stringlist: function stringlist(operator, values, scope, invert) {
values = Array.concat(values);
values = [].concat(values);

function uniq(ary) {
let seen = new RealSet;
Expand All @@ -767,10 +767,10 @@ var Option = Class("Option", {

switch (operator) {
case "+":
return uniq(Array.concat(this.value, values), true);
return uniq([].concat(this.value, values), true);
case "^":
// NOTE: Vim doesn't prepend if there's a match in the current value
return uniq(Array.concat(values, this.value), true);
return uniq([].concat(values, this.value), true);
case "-":
return this.value.filter(function (item) {
return !this.has(item);
Expand Down Expand Up @@ -839,9 +839,9 @@ var Option = Class("Option", {
acceptable = new RealSet(Object.keys(acceptable).map(k => this.parseKey(k)));

if (this.type === "regexpmap" || this.type === "sitemap")
return Array.concat(vals).every(re => acceptable.has(re.result));
return [].concat(vals).every(re => acceptable.has(re.result));

return Array.concat(vals).every(v => acceptable.has(v));
return [].concat(vals).every(v => acceptable.has(v));
},

types: {}
Expand Down
2 changes: 1 addition & 1 deletion common/modules/overlay.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
if (url instanceof Ci.nsIDOMWindow)
overlay._loadOverlay(url, fn);
else {
Array.concat(url).forEach(function (url) {
[].concat(url).forEach(function (url) {
let matcher = this.matchFilter(url);
if (!matcher.exact)
this.overlayMatchers.push([matcher, fn]);
Expand Down
6 changes: 3 additions & 3 deletions common/modules/services.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ var Services = Module("Services", {
*/
add: function add(name, class_, ifaces, meth) {
const self = this;
this.services[name] = { method: meth, class: class_, interfaces: Array.concat(ifaces || []) };
this.services[name] = { method: meth, class: class_, interfaces: [].concat(ifaces || []) };
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
throw TypeError();
memoize(this, name, () => self._create(name));
Expand All @@ -177,7 +177,7 @@ var Services = Module("Services", {
*/
addClass: function addClass(name, class_, ifaces, init = null, quiet = true) {
this.services[name] = { class: class_,
interfaces: Array.concat(ifaces || []),
interfaces: [].concat(ifaces || []),
method: "createInstance",
init: init,
quiet: quiet };
Expand All @@ -190,7 +190,7 @@ var Services = Module("Services", {
this[name] = (...args) => this._create(name, args);

update(this[name],
...Array.concat(ifaces).map(iface => Ci[iface]));
...[].concat(ifaces).map(iface => Ci[iface]));

return this[name];
},
Expand Down
2 changes: 1 addition & 1 deletion common/modules/template.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ var Template = Module("Template", {
_i = i;

s.push(str.substring(start, i),
highlight.apply(this, Array.concat(args || str.substr(i, length))));
highlight.apply(this, [].concat(args || str.substr(i, length))));
start = i + length;
}
s.push(str.substr(start));
Expand Down
12 changes: 6 additions & 6 deletions common/tests/functional/testCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ var tests = {
["! " + name, sidebarState(false)]
],
get noOutput()
Array.concat.apply([],
[].concat.apply([],
["Add-ons", // Final "! Add-ons" currently failing
"Bookmarks",
"Downloads",
Expand Down Expand Up @@ -953,7 +953,7 @@ function addTest(cmdName, testName, func) {
function runCommands(cmdName, testName, commands, test, forbidErrors) {
addTest(cmdName, testName, function () {
commands.forEach(function (val) {
var [cmd, testVal] = Array.concat(val);
var [cmd, testVal] = [].concat(val);

dump("CMD: " + testName + " " + cmdName + " " + cmd + "\n");
dactyl.clearMessage();
Expand All @@ -974,7 +974,7 @@ function runCommands(cmdName, testName, commands, test, forbidErrors) {
function _runCommands(cmdName, testName, commands) {
addTest(cmdName, testName, function () {
commands.forEach(function (value) {
var [cmd, test] = Array.concat(value);
var [cmd, test] = [].concat(value);

dump("CMD: " + testName + " " + cmdName + " " + cmd + "\n");
var res = dactyl.runExCommand(cmd);
Expand All @@ -993,7 +993,7 @@ function runTest(message, test, ...args) {
}

for (var val in Iterator(tests)) (function ([command, paramsList]) {
Array.concat(paramsList).forEach(function (params, i) {
[].concat(paramsList).forEach(function (params, i) {
if (params.init)
_runCommands(command, "init" + (i || ""), params.init);

Expand Down Expand Up @@ -1039,7 +1039,7 @@ for (var val in Iterator(tests)) (function ([command, paramsList]) {
case "error":
addTest(command, testName, function () {
commands.forEach(function (val) {
var [cmd, test] = Array.concat(val);
var [cmd, test] = [].concat(val);
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");

var res = dactyl.assertMessageError(function () {
Expand All @@ -1055,7 +1055,7 @@ for (var val in Iterator(tests)) (function ([command, paramsList]) {
case "completions":
addTest(command, testName, function () {
commands.forEach(function (val) {
var [cmd, test] = Array.concat(val);
var [cmd, test] = [].concat(val);
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");

dactyl.assertNoErrorMessages(function () {
Expand Down
4 changes: 2 additions & 2 deletions plugins/noscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getSites() {
const blockUntrusted = global && ns.alwaysBlockUntrustedContent;

let res = [];
for (let site of array.iterValues(Array.concat(sites.topSite, sites))) {
for (let site of array.iterValues([].concat(sites.topSite, sites))) {
let ary = [];

let untrusted = groups.untrusted.matches(site);
Expand Down Expand Up @@ -311,7 +311,7 @@ group.options.add(["script"],
names: ["noscript-objects", "nso"],
description: "The list of allowed objects",
get set() { return new RealSet(array.flatten(
[Array.concat(v).map(function (v) { return v + "@" + this; }, k)
[[].concat(v).map(function (v) { return v + "@" + this; }, k)
for ([k, v] of iter(services.noscript.objectWhitelist))])) },
action: function (add, patterns) {
for (let pattern of values(patterns)) {
Expand Down