mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-08 21:14:13 +01:00
Remove unnecessary use of values() when iterating over arrays.
This commit is contained in:
@@ -172,7 +172,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
|
||||
* @param {Array} modes List of modes.
|
||||
*/
|
||||
clear: function (modes) {
|
||||
for (let mode of values(modes)) {
|
||||
for (let mode of modes) {
|
||||
for (let abbr of values(this._store[mode]))
|
||||
abbr.removeMode(mode);
|
||||
delete this._store[mode];
|
||||
|
||||
@@ -38,7 +38,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
|
||||
if (!callable(pattern))
|
||||
pattern = Group.compileFilter(pattern);
|
||||
|
||||
for (let event of values(events))
|
||||
for (let event of events)
|
||||
this._store.push(AutoCommand(event, pattern, cmd));
|
||||
},
|
||||
|
||||
@@ -144,10 +144,10 @@ var AutoCommands = Module("autocommands", {
|
||||
var { uri, doc } = buffer;
|
||||
|
||||
event = event.toLowerCase();
|
||||
for (let hive of values(this.matchingHives(uri, doc))) {
|
||||
for (let hive of this.matchingHives(uri, doc)) {
|
||||
let args = hive.makeArgs(doc, null, arguments[1]);
|
||||
|
||||
for (let autoCmd of values(hive._store))
|
||||
for (let autoCmd of hive._store)
|
||||
if (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
|
||||
if (!lastPattern || lastPattern !== String(autoCmd.filter))
|
||||
dactyl.echomsg(_("autocmd.executing", event, autoCmd.filter), 8);
|
||||
|
||||
@@ -160,7 +160,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
let oldURI = overlay.getData(win.document)["uri"];
|
||||
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||
for (let frame of values(buffer.allFrames(win)))
|
||||
for (let frame of buffer.allFrames(win))
|
||||
overlay.setData(frame.document, "focus-allowed", false);
|
||||
|
||||
overlay.setData(win.document, "uri", uri.spec);
|
||||
|
||||
@@ -635,7 +635,7 @@ var CommandLine = Module("commandline", {
|
||||
},
|
||||
|
||||
hideCompletions: function hideCompletions() {
|
||||
for (let nodeSet of values([this.widgets.statusbar, this.widgets.commandbar]))
|
||||
for (let nodeSet of [this.widgets.statusbar, this.widgets.commandbar])
|
||||
if (nodeSet.commandline.completionList)
|
||||
nodeSet.commandline.completionList.visible = false;
|
||||
},
|
||||
@@ -2090,7 +2090,7 @@ var ItemList = Class("ItemList", {
|
||||
updateOffsets: function updateOffsets() {
|
||||
let total = this.itemCount;
|
||||
let count = 0;
|
||||
for (let group of values(this.activeGroups)) {
|
||||
for (let group of this.activeGroups) {
|
||||
group.offsets = { start: count, end: total - count - group.itemCount };
|
||||
count += group.itemCount;
|
||||
}
|
||||
@@ -2105,7 +2105,8 @@ var ItemList = Class("ItemList", {
|
||||
|
||||
let container = DOM(this.nodes.completions);
|
||||
let groups = this.activeGroups;
|
||||
for (let group of values(groups)) {
|
||||
|
||||
for (let group of groups) {
|
||||
group.reset();
|
||||
container.append(group.nodes.root);
|
||||
}
|
||||
@@ -2148,7 +2149,7 @@ var ItemList = Class("ItemList", {
|
||||
* @private
|
||||
*/
|
||||
draw: function draw() {
|
||||
for (let group of values(this.activeGroups))
|
||||
for (let group of this.activeGroups)
|
||||
group.draw();
|
||||
|
||||
// We need to collect all of the rescrolling functions in
|
||||
|
||||
@@ -47,7 +47,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
for (let cleanup of values(this.cleanups))
|
||||
for (let cleanup of this.cleanups)
|
||||
cleanup.call(this);
|
||||
|
||||
delete window.dactyl;
|
||||
@@ -87,7 +87,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"dactyl-cleanup": function dactyl_cleanup(subject, reason) {
|
||||
let modules = dactyl.modules;
|
||||
|
||||
for (let mod of values(modules.moduleList.reverse())) {
|
||||
for (let mod of modules.moduleList.reverse()) {
|
||||
mod.stale = true;
|
||||
if ("cleanup" in mod)
|
||||
this.trapErrors("cleanup", mod, reason);
|
||||
@@ -97,7 +97,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
modules.moduleManager.initDependencies("cleanup");
|
||||
|
||||
for (let name of values(Object.getOwnPropertyNames(modules).reverse()))
|
||||
for (let name of Object.getOwnPropertyNames(modules).reverse())
|
||||
try {
|
||||
delete modules[name];
|
||||
}
|
||||
@@ -272,7 +272,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let results = Ary((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
|
||||
.array.sort((a, b) => String.localeCompare(a.name, b.name));
|
||||
|
||||
for (let obj of values(results)) {
|
||||
for (let obj of results) {
|
||||
let res = dactyl.generateHelp(obj, null, null, true);
|
||||
if (!hasOwnProperty(help.tags, obj.helpTag))
|
||||
res[0][1].tag = obj.helpTag;
|
||||
@@ -1402,7 +1402,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
.flatten(),
|
||||
|
||||
setter: function (value) {
|
||||
for (let group of values(groups))
|
||||
for (let group of groups)
|
||||
group.setter(value);
|
||||
events.checkFocus();
|
||||
return value;
|
||||
@@ -1991,7 +1991,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
// after sourcing the initialization files, this function will set
|
||||
// all gui options to their default values, if they have not been
|
||||
// set before by any RC file
|
||||
for (let option of values(options.needInit))
|
||||
for (let option of options.needInit)
|
||||
option.initValue();
|
||||
|
||||
if (dactyl.commandLineOptions.postCommands)
|
||||
|
||||
@@ -447,7 +447,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
if (!keepFocus)
|
||||
dactyl.focus(textBox);
|
||||
|
||||
for (let group of values(blink.concat(blink, ""))) {
|
||||
for (let group of blink.concat(blink, "")) {
|
||||
highlight.highlightNode(textBox, origGroup + " " + group);
|
||||
|
||||
yield promises.sleep(100);
|
||||
|
||||
@@ -375,7 +375,7 @@ var Events = Module("events", {
|
||||
|
||||
for (let evt_obj of DOM.Event.parse(keys)) {
|
||||
let key = DOM.Event.stringify(evt_obj);
|
||||
for (let type of values(["keydown", "keypress", "keyup"])) {
|
||||
for (let type of ["keydown", "keypress", "keyup"]) {
|
||||
let evt = update({}, evt_obj, { type: type });
|
||||
if (type !== "keypress" && !evt.keyCode)
|
||||
evt.keyCode = evt._keyCode || 0;
|
||||
@@ -480,7 +480,7 @@ var Events = Module("events", {
|
||||
let needed = { ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey, metaKey: event.metaKey };
|
||||
|
||||
let modifiers = (key.getAttribute("modifiers") || "").trim().split(/[\s,]+/);
|
||||
for (let modifier of values(modifiers))
|
||||
for (let modifier of modifiers)
|
||||
switch (modifier) {
|
||||
case "access": update(keys, access); break;
|
||||
case "accel": keys[accel] = true; break;
|
||||
@@ -780,7 +780,7 @@ var Events = Module("events", {
|
||||
if (this.feedingKeys)
|
||||
this.duringFeed = this.duringFeed.concat(duringFeed);
|
||||
else
|
||||
for (let event of values(duringFeed))
|
||||
for (let event of duringFeed)
|
||||
try {
|
||||
DOM.Event.dispatch(event.originalTarget, event, event);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
// those waiting on further arguments. Execute actions as
|
||||
// long as they continue to return PASS.
|
||||
|
||||
for (var action of values(this.actions)) {
|
||||
for (var action of this.actions) {
|
||||
while (callable(action)) {
|
||||
length = action.eventLength;
|
||||
action = dactyl.trapErrors(action);
|
||||
@@ -196,14 +196,14 @@ var ProcessorStack = Class("ProcessorStack", {
|
||||
this._actions = actions;
|
||||
this.actions = actions.concat(this.actions);
|
||||
|
||||
for (let action of values(actions))
|
||||
for (let action of actions)
|
||||
if (!("eventLength" in action))
|
||||
action.eventLength = this.events.length;
|
||||
|
||||
if (result === Events.KILL)
|
||||
this.actions = [];
|
||||
else if (!this.actions.length && !processors.length)
|
||||
for (let input of values(this.processors))
|
||||
for (let input of this.processors)
|
||||
if (input.fallthrough) {
|
||||
if (result === Events.KILL)
|
||||
break;
|
||||
|
||||
@@ -201,7 +201,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
for (let mode of map.modes)
|
||||
this.remove(mode, name);
|
||||
|
||||
for (let mode of values(map.modes))
|
||||
for (let mode of map.modes)
|
||||
this.getStack(mode).add(map);
|
||||
return map;
|
||||
},
|
||||
@@ -301,7 +301,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
};
|
||||
|
||||
for (let map of this)
|
||||
for (let name of values(map.keys)) {
|
||||
for (let name of map.keys) {
|
||||
states.mappings[name] = map;
|
||||
let state = "";
|
||||
for (let key of DOM.Event.iterKeys(name)) {
|
||||
@@ -674,7 +674,7 @@ var Mappings = Module("mappings", {
|
||||
let mapmodes = Ary.uniq(args["-modes"].map(findMode));
|
||||
|
||||
let found = 0;
|
||||
for (let mode of values(mapmodes))
|
||||
for (let mode of mapmodes)
|
||||
if (args.bang)
|
||||
args["-group"].clear(mode);
|
||||
else if (args["-group"].has(mode, args[0])) {
|
||||
@@ -707,13 +707,13 @@ var Mappings = Module("mappings", {
|
||||
type: CommandOption.STRING,
|
||||
validator: function (value) Array.concat(value).every(findMode),
|
||||
completer: function () [[Ary.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.description]
|
||||
for (mode of values(modes.all))
|
||||
for (mode of modes.all)
|
||||
if (!mode.hidden)]
|
||||
};
|
||||
|
||||
function findMode(name) {
|
||||
if (name)
|
||||
for (let mode of values(modes.all))
|
||||
for (let mode of modes.all)
|
||||
if (name == mode || name == mode.char
|
||||
|| String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
|
||||
return mode;
|
||||
@@ -762,7 +762,7 @@ var Mappings = Module("mappings", {
|
||||
for (let [i, mode] of iter(modes))
|
||||
for (let hive of mappings.hives.iterValues())
|
||||
for (let map of Ary.iterValues(hive.getStack(mode)))
|
||||
for (let name of values(map.names))
|
||||
for (let name of map.names)
|
||||
if (!seen.add(name))
|
||||
yield {
|
||||
name: name,
|
||||
|
||||
@@ -150,7 +150,7 @@ var Modes = Module("modes", {
|
||||
dactyl.focusContent(true);
|
||||
if (prev.main == modes.NORMAL) {
|
||||
dactyl.focusContent(true);
|
||||
for (let frame of values(buffer.allFrames())) {
|
||||
for (let frame of buffer.allFrames()) {
|
||||
// clear any selection made
|
||||
let selection = frame.getSelection();
|
||||
if (selection && !selection.isCollapsed)
|
||||
@@ -539,15 +539,15 @@ var Modes = Module("modes", {
|
||||
|
||||
let tree = {};
|
||||
|
||||
for (let mode of values(list))
|
||||
for (let mode of list)
|
||||
tree[mode.name] = {};
|
||||
|
||||
for (let mode of values(list))
|
||||
for (let base of values(mode.bases))
|
||||
for (let mode of list)
|
||||
for (let base of mode.bases)
|
||||
tree[base.name][mode.name] = tree[mode.name];
|
||||
|
||||
let roots = iter([m.name, tree[m.name]]
|
||||
for (m of values(list))
|
||||
for (m of list)
|
||||
if (!m.bases.length)).toObject();
|
||||
|
||||
function rec(obj) {
|
||||
@@ -634,7 +634,7 @@ var Modes = Module("modes", {
|
||||
.every(k => hasOwnProperty(this.values, k)),
|
||||
|
||||
get values() Ary.toObject([[m.name.toLowerCase(), m.description]
|
||||
for (m of values(modes._modes)) if (!m.hidden)])
|
||||
for (m of modes._modes) if (!m.hidden)])
|
||||
};
|
||||
|
||||
options.add(["passunknown", "pu"],
|
||||
|
||||
@@ -95,7 +95,7 @@ var MOW = Module("mow", {
|
||||
|
||||
leave: stack => {
|
||||
if (stack.pop)
|
||||
for (let message of values(this.messages))
|
||||
for (let message of this.messages)
|
||||
if (message.leave)
|
||||
message.leave(stack);
|
||||
},
|
||||
|
||||
@@ -63,7 +63,7 @@ var Tabs = Module("tabs", {
|
||||
cleanup: function cleanup() {
|
||||
for (let tab of this.allTabs) {
|
||||
let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_);
|
||||
for (let elem of values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||
for (let elem of ["dactyl-tab-icon-number", "dactyl-tab-number"].map(node))
|
||||
if (elem)
|
||||
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
||||
|
||||
@@ -369,7 +369,7 @@ var Tabs = Module("tabs", {
|
||||
else
|
||||
var matcher = Styles.matchFilter(filter);
|
||||
|
||||
for (let tab of values(tabs[all ? "allTabs" : "visibleTabs"])) {
|
||||
for (let tab of tabs[all ? "allTabs" : "visibleTabs"]) {
|
||||
let browser = tab.linkedBrowser;
|
||||
let uri = browser.currentURI;
|
||||
let title;
|
||||
@@ -719,7 +719,7 @@ var Tabs = Module("tabs", {
|
||||
commands.add(["tabd[o]", "bufd[o]"],
|
||||
"Execute a command in each tab",
|
||||
function (args) {
|
||||
for (let tab of values(tabs.visibleTabs)) {
|
||||
for (let tab of tabs.visibleTabs) {
|
||||
tabs.select(tab);
|
||||
dactyl.execute(args[0], null, true);
|
||||
}
|
||||
@@ -1256,13 +1256,13 @@ var Tabs = Module("tabs", {
|
||||
];
|
||||
options.add(["activate", "act"],
|
||||
"Define when newly created tabs are automatically activated",
|
||||
"stringlist", [g[0] for (g of values(activateGroups.slice(1))) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
|
||||
"stringlist", [g[0] for (g of activateGroups.slice(1)) if (!g[2] || !prefs.get("browser.tabs." + g[2]))].join(","),
|
||||
{
|
||||
values: activateGroups,
|
||||
has: Option.has.toggleAll,
|
||||
setter: function (newValues) {
|
||||
let valueSet = new RealSet(newValues);
|
||||
for (let group of values(activateGroups))
|
||||
for (let group of activateGroups)
|
||||
if (group[2])
|
||||
prefs.safeSet("browser.tabs." + group[2],
|
||||
!(valueSet.has("all") ^ valueSet.has(group[0])),
|
||||
|
||||
Reference in New Issue
Block a user