1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-28 05:03:31 +01:00

Remove unnecessary use of values() when iterating over arrays.

This commit is contained in:
Doug Kearns
2015-05-11 23:56:31 +10:00
parent a8e70d3f43
commit 48acf656ec
27 changed files with 81 additions and 80 deletions

View File

@@ -172,7 +172,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
* @param {Array} modes List of modes. * @param {Array} modes List of modes.
*/ */
clear: function (modes) { clear: function (modes) {
for (let mode of values(modes)) { for (let mode of modes) {
for (let abbr of values(this._store[mode])) for (let abbr of values(this._store[mode]))
abbr.removeMode(mode); abbr.removeMode(mode);
delete this._store[mode]; delete this._store[mode];

View File

@@ -38,7 +38,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
if (!callable(pattern)) if (!callable(pattern))
pattern = Group.compileFilter(pattern); pattern = Group.compileFilter(pattern);
for (let event of values(events)) for (let event of events)
this._store.push(AutoCommand(event, pattern, cmd)); this._store.push(AutoCommand(event, pattern, cmd));
}, },
@@ -144,10 +144,10 @@ var AutoCommands = Module("autocommands", {
var { uri, doc } = buffer; var { uri, doc } = buffer;
event = event.toLowerCase(); 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]); 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 (autoCmd.eventName === event && autoCmd.filter(uri, doc)) {
if (!lastPattern || lastPattern !== String(autoCmd.filter)) if (!lastPattern || lastPattern !== String(autoCmd.filter))
dactyl.echomsg(_("autocmd.executing", event, autoCmd.filter), 8); dactyl.echomsg(_("autocmd.executing", event, autoCmd.filter), 8);

View File

@@ -160,7 +160,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
let oldURI = overlay.getData(win.document)["uri"]; let oldURI = overlay.getData(win.document)["uri"];
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, "")) || !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(frame.document, "focus-allowed", false);
overlay.setData(win.document, "uri", uri.spec); overlay.setData(win.document, "uri", uri.spec);

View File

@@ -635,7 +635,7 @@ var CommandLine = Module("commandline", {
}, },
hideCompletions: function hideCompletions() { 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) if (nodeSet.commandline.completionList)
nodeSet.commandline.completionList.visible = false; nodeSet.commandline.completionList.visible = false;
}, },
@@ -2090,7 +2090,7 @@ var ItemList = Class("ItemList", {
updateOffsets: function updateOffsets() { updateOffsets: function updateOffsets() {
let total = this.itemCount; let total = this.itemCount;
let count = 0; 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 }; group.offsets = { start: count, end: total - count - group.itemCount };
count += group.itemCount; count += group.itemCount;
} }
@@ -2105,7 +2105,8 @@ var ItemList = Class("ItemList", {
let container = DOM(this.nodes.completions); let container = DOM(this.nodes.completions);
let groups = this.activeGroups; let groups = this.activeGroups;
for (let group of values(groups)) {
for (let group of groups) {
group.reset(); group.reset();
container.append(group.nodes.root); container.append(group.nodes.root);
} }
@@ -2148,7 +2149,7 @@ var ItemList = Class("ItemList", {
* @private * @private
*/ */
draw: function draw() { draw: function draw() {
for (let group of values(this.activeGroups)) for (let group of this.activeGroups)
group.draw(); group.draw();
// We need to collect all of the rescrolling functions in // We need to collect all of the rescrolling functions in

View File

@@ -47,7 +47,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
cleanup: function () { cleanup: function () {
for (let cleanup of values(this.cleanups)) for (let cleanup of this.cleanups)
cleanup.call(this); cleanup.call(this);
delete window.dactyl; delete window.dactyl;
@@ -87,7 +87,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
"dactyl-cleanup": function dactyl_cleanup(subject, reason) { "dactyl-cleanup": function dactyl_cleanup(subject, reason) {
let modules = dactyl.modules; let modules = dactyl.modules;
for (let mod of values(modules.moduleList.reverse())) { for (let mod of modules.moduleList.reverse()) {
mod.stale = true; mod.stale = true;
if ("cleanup" in mod) if ("cleanup" in mod)
this.trapErrors("cleanup", mod, reason); this.trapErrors("cleanup", mod, reason);
@@ -97,7 +97,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
modules.moduleManager.initDependencies("cleanup"); modules.moduleManager.initDependencies("cleanup");
for (let name of values(Object.getOwnPropertyNames(modules).reverse())) for (let name of Object.getOwnPropertyNames(modules).reverse())
try { try {
delete modules[name]; 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())) let results = Ary((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
.array.sort((a, b) => String.localeCompare(a.name, b.name)); .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); let res = dactyl.generateHelp(obj, null, null, true);
if (!hasOwnProperty(help.tags, obj.helpTag)) if (!hasOwnProperty(help.tags, obj.helpTag))
res[0][1].tag = obj.helpTag; res[0][1].tag = obj.helpTag;
@@ -1402,7 +1402,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
.flatten(), .flatten(),
setter: function (value) { setter: function (value) {
for (let group of values(groups)) for (let group of groups)
group.setter(value); group.setter(value);
events.checkFocus(); events.checkFocus();
return value; return value;
@@ -1991,7 +1991,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
// after sourcing the initialization files, this function will set // after sourcing the initialization files, this function will set
// all gui options to their default values, if they have not been // all gui options to their default values, if they have not been
// set before by any RC file // set before by any RC file
for (let option of values(options.needInit)) for (let option of options.needInit)
option.initValue(); option.initValue();
if (dactyl.commandLineOptions.postCommands) if (dactyl.commandLineOptions.postCommands)

View File

@@ -447,7 +447,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
if (!keepFocus) if (!keepFocus)
dactyl.focus(textBox); dactyl.focus(textBox);
for (let group of values(blink.concat(blink, ""))) { for (let group of blink.concat(blink, "")) {
highlight.highlightNode(textBox, origGroup + " " + group); highlight.highlightNode(textBox, origGroup + " " + group);
yield promises.sleep(100); yield promises.sleep(100);

View File

@@ -375,7 +375,7 @@ var Events = Module("events", {
for (let evt_obj of DOM.Event.parse(keys)) { for (let evt_obj of DOM.Event.parse(keys)) {
let key = DOM.Event.stringify(evt_obj); 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 }); let evt = update({}, evt_obj, { type: type });
if (type !== "keypress" && !evt.keyCode) if (type !== "keypress" && !evt.keyCode)
evt.keyCode = evt._keyCode || 0; 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 needed = { ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey, metaKey: event.metaKey };
let modifiers = (key.getAttribute("modifiers") || "").trim().split(/[\s,]+/); let modifiers = (key.getAttribute("modifiers") || "").trim().split(/[\s,]+/);
for (let modifier of values(modifiers)) for (let modifier of modifiers)
switch (modifier) { switch (modifier) {
case "access": update(keys, access); break; case "access": update(keys, access); break;
case "accel": keys[accel] = true; break; case "accel": keys[accel] = true; break;
@@ -780,7 +780,7 @@ var Events = Module("events", {
if (this.feedingKeys) if (this.feedingKeys)
this.duringFeed = this.duringFeed.concat(duringFeed); this.duringFeed = this.duringFeed.concat(duringFeed);
else else
for (let event of values(duringFeed)) for (let event of duringFeed)
try { try {
DOM.Event.dispatch(event.originalTarget, event, event); DOM.Event.dispatch(event.originalTarget, event, event);
} }

View File

@@ -81,7 +81,7 @@ var ProcessorStack = Class("ProcessorStack", {
// those waiting on further arguments. Execute actions as // those waiting on further arguments. Execute actions as
// long as they continue to return PASS. // long as they continue to return PASS.
for (var action of values(this.actions)) { for (var action of this.actions) {
while (callable(action)) { while (callable(action)) {
length = action.eventLength; length = action.eventLength;
action = dactyl.trapErrors(action); action = dactyl.trapErrors(action);
@@ -196,14 +196,14 @@ var ProcessorStack = Class("ProcessorStack", {
this._actions = actions; this._actions = actions;
this.actions = actions.concat(this.actions); this.actions = actions.concat(this.actions);
for (let action of values(actions)) for (let action of actions)
if (!("eventLength" in action)) if (!("eventLength" in action))
action.eventLength = this.events.length; action.eventLength = this.events.length;
if (result === Events.KILL) if (result === Events.KILL)
this.actions = []; this.actions = [];
else if (!this.actions.length && !processors.length) else if (!this.actions.length && !processors.length)
for (let input of values(this.processors)) for (let input of this.processors)
if (input.fallthrough) { if (input.fallthrough) {
if (result === Events.KILL) if (result === Events.KILL)
break; break;

View File

@@ -201,7 +201,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
for (let mode of map.modes) for (let mode of map.modes)
this.remove(mode, name); this.remove(mode, name);
for (let mode of values(map.modes)) for (let mode of map.modes)
this.getStack(mode).add(map); this.getStack(mode).add(map);
return map; return map;
}, },
@@ -301,7 +301,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
}; };
for (let map of this) for (let map of this)
for (let name of values(map.keys)) { for (let name of map.keys) {
states.mappings[name] = map; states.mappings[name] = map;
let state = ""; let state = "";
for (let key of DOM.Event.iterKeys(name)) { 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 mapmodes = Ary.uniq(args["-modes"].map(findMode));
let found = 0; let found = 0;
for (let mode of values(mapmodes)) for (let mode of mapmodes)
if (args.bang) if (args.bang)
args["-group"].clear(mode); args["-group"].clear(mode);
else if (args["-group"].has(mode, args[0])) { else if (args["-group"].has(mode, args[0])) {
@@ -707,13 +707,13 @@ var Mappings = Module("mappings", {
type: CommandOption.STRING, type: CommandOption.STRING,
validator: function (value) Array.concat(value).every(findMode), validator: function (value) Array.concat(value).every(findMode),
completer: function () [[Ary.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.description] 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)] if (!mode.hidden)]
}; };
function findMode(name) { function findMode(name) {
if (name) if (name)
for (let mode of values(modes.all)) for (let mode of modes.all)
if (name == mode || name == mode.char if (name == mode || name == mode.char
|| String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase()) || String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
return mode; return mode;
@@ -762,7 +762,7 @@ var Mappings = Module("mappings", {
for (let [i, mode] of iter(modes)) for (let [i, mode] of iter(modes))
for (let hive of mappings.hives.iterValues()) for (let hive of mappings.hives.iterValues())
for (let map of Ary.iterValues(hive.getStack(mode))) 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)) if (!seen.add(name))
yield { yield {
name: name, name: name,

View File

@@ -150,7 +150,7 @@ var Modes = Module("modes", {
dactyl.focusContent(true); dactyl.focusContent(true);
if (prev.main == modes.NORMAL) { if (prev.main == modes.NORMAL) {
dactyl.focusContent(true); dactyl.focusContent(true);
for (let frame of values(buffer.allFrames())) { for (let frame of buffer.allFrames()) {
// clear any selection made // clear any selection made
let selection = frame.getSelection(); let selection = frame.getSelection();
if (selection && !selection.isCollapsed) if (selection && !selection.isCollapsed)
@@ -539,15 +539,15 @@ var Modes = Module("modes", {
let tree = {}; let tree = {};
for (let mode of values(list)) for (let mode of list)
tree[mode.name] = {}; tree[mode.name] = {};
for (let mode of values(list)) for (let mode of list)
for (let base of values(mode.bases)) for (let base of mode.bases)
tree[base.name][mode.name] = tree[mode.name]; tree[base.name][mode.name] = tree[mode.name];
let roots = iter([m.name, tree[m.name]] let roots = iter([m.name, tree[m.name]]
for (m of values(list)) for (m of list)
if (!m.bases.length)).toObject(); if (!m.bases.length)).toObject();
function rec(obj) { function rec(obj) {
@@ -634,7 +634,7 @@ var Modes = Module("modes", {
.every(k => hasOwnProperty(this.values, k)), .every(k => hasOwnProperty(this.values, k)),
get values() Ary.toObject([[m.name.toLowerCase(), m.description] 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"], options.add(["passunknown", "pu"],

View File

@@ -95,7 +95,7 @@ var MOW = Module("mow", {
leave: stack => { leave: stack => {
if (stack.pop) if (stack.pop)
for (let message of values(this.messages)) for (let message of this.messages)
if (message.leave) if (message.leave)
message.leave(stack); message.leave(stack);
}, },

View File

@@ -63,7 +63,7 @@ var Tabs = Module("tabs", {
cleanup: function cleanup() { cleanup: function cleanup() {
for (let tab of this.allTabs) { for (let tab of this.allTabs) {
let node = function node(class_) document.getAnonymousElementByAttribute(tab, "class", class_); 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) if (elem)
elem.parentNode.parentNode.removeChild(elem.parentNode); elem.parentNode.parentNode.removeChild(elem.parentNode);
@@ -369,7 +369,7 @@ var Tabs = Module("tabs", {
else else
var matcher = Styles.matchFilter(filter); 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 browser = tab.linkedBrowser;
let uri = browser.currentURI; let uri = browser.currentURI;
let title; let title;
@@ -719,7 +719,7 @@ var Tabs = Module("tabs", {
commands.add(["tabd[o]", "bufd[o]"], commands.add(["tabd[o]", "bufd[o]"],
"Execute a command in each tab", "Execute a command in each tab",
function (args) { function (args) {
for (let tab of values(tabs.visibleTabs)) { for (let tab of tabs.visibleTabs) {
tabs.select(tab); tabs.select(tab);
dactyl.execute(args[0], null, true); dactyl.execute(args[0], null, true);
} }
@@ -1256,13 +1256,13 @@ var Tabs = Module("tabs", {
]; ];
options.add(["activate", "act"], options.add(["activate", "act"],
"Define when newly created tabs are automatically activated", "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, values: activateGroups,
has: Option.has.toggleAll, has: Option.has.toggleAll,
setter: function (newValues) { setter: function (newValues) {
let valueSet = new RealSet(newValues); let valueSet = new RealSet(newValues);
for (let group of values(activateGroups)) for (let group of activateGroups)
if (group[2]) if (group[2])
prefs.safeSet("browser.tabs." + group[2], prefs.safeSet("browser.tabs." + group[2],
!(valueSet.has("all") ^ valueSet.has(group[0])), !(valueSet.has("all") ^ valueSet.has(group[0])),

View File

@@ -54,7 +54,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
this.remaining = addons; this.remaining = addons;
this.upgrade = []; this.upgrade = [];
this.dactyl.echomsg(_("addon.check", addons.map(a => a.name).join(", "))); this.dactyl.echomsg(_("addon.check", addons.map(a => a.name).join(", ")));
for (let addon of values(addons)) for (let addon of addons)
addon.findUpdates(this, AddonManager.UPDATE_WHEN_USER_REQUESTED, null, null); addon.findUpdates(this, AddonManager.UPDATE_WHEN_USER_REQUESTED, null, null);
}, },

View File

@@ -377,7 +377,7 @@ deprecated.warn = function warn(func, name, alternative, frame) {
* object. * object.
* *
* @param {object} obj The object to inspect. * @param {object} obj The object to inspect.
* @returns {Generator} * @returns {Iter}
*/ */
function keys(obj) { function keys(obj) {
if (isinstance(obj, ["Map"])) if (isinstance(obj, ["Map"]))
@@ -392,7 +392,7 @@ function keys(obj) {
* object. * object.
* *
* @param {object} obj The object to inspect. * @param {object} obj The object to inspect.
* @returns {Generator} * @returns {Iter}
*/ */
function values(obj) { function values(obj) {
if (isinstance(obj, ["Map"])) if (isinstance(obj, ["Map"]))
@@ -458,7 +458,7 @@ Object.defineProperty(RealSet.prototype, "union", {
this.Set = deprecated("RealSet", function Set(ary) { this.Set = deprecated("RealSet", function Set(ary) {
let obj = {}; let obj = {};
if (ary) if (ary)
for (let val of values(ary)) for (let val of ary)
obj[val] = true; obj[val] = true;
return obj; return obj;
}); });
@@ -1528,7 +1528,7 @@ function iter(obj, iface) {
res = Ary.iterItems(obj); res = Ary.iterItems(obj);
else if (obj.constructor instanceof ctypes.StructType) else if (obj.constructor instanceof ctypes.StructType)
res = (function* () { res = (function* () {
for (let prop of values(obj.constructor.fields)) { for (let prop of obj.constructor.fields) {
let [name, type] = Iterator(prop).next(); let [name, type] = Iterator(prop).next();
yield [name, obj[name]]; yield [name, obj[name]];
} }
@@ -1849,7 +1849,7 @@ var Ary = Class("Ary", Array, {
* given predicate. * given predicate.
*/ */
nth: function nth(ary, pred, n, self) { nth: function nth(ary, pred, n, self) {
for (let elem of values(ary)) for (let elem of ary)
if (pred.call(self, elem) && n-- === 0) if (pred.call(self, elem) && n-- === 0)
return elem; return elem;
return undefined; return undefined;

View File

@@ -125,7 +125,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
get: function (url) { get: function (url) {
let ids = services.bookmarks.getBookmarkIdsForURI(newURI(url), {}); let ids = services.bookmarks.getBookmarkIdsForURI(newURI(url), {});
for (let id of values(ids)) for (let id of ids)
if (id in this.bookmarks) if (id in this.bookmarks)
return this.bookmarks[id]; return this.bookmarks[id];
return null; return null;

View File

@@ -525,13 +525,13 @@ var Buffer = Module("Buffer", {
Hints.isVisible); Hints.isVisible);
for (let test of [a, b]) for (let test of [a, b])
for (let regexp of values(regexps)) for (let regexp of regexps)
for (let i of util.range(res.length, 0, -1)) for (let i of util.range(res.length, 0, -1))
if (test(regexp, res[i])) if (test(regexp, res[i]))
yield res[i]; yield res[i];
} }
for (let frame of values(this.allFrames(null, true))) for (let frame of this.allFrames(null, true))
for (let elem of followFrame(frame)) for (let elem of followFrame(frame))
if (count-- === 0) { if (count-- === 0) {
if (follow) if (follow)
@@ -2045,7 +2045,7 @@ var Buffer = Module("Buffer", {
context.title = ["Stylesheet", "Location"]; context.title = ["Stylesheet", "Location"];
// unify split style sheets // unify split style sheets
let styles = iter([s.title, []] for (s of values(buffer.alternateStyleSheets))).toObject(); let styles = iter([s.title, []] for (s of buffer.alternateStyleSheets)).toObject();
buffer.alternateStyleSheets.forEach(function (style) { buffer.alternateStyleSheets.forEach(function (style) {
styles[style.title].push(style.href || _("style.inline")); styles[style.title].push(style.href || _("style.inline"));
@@ -2506,7 +2506,7 @@ var Buffer = Module("Buffer", {
{ {
getLine: function getLine(doc, line) { getLine: function getLine(doc, line) {
let uri = util.newURI(doc.documentURI); let uri = util.newURI(doc.documentURI);
for (let filter of values(this.value)) for (let filter of this.value)
if (filter(uri, doc)) { if (filter(uri, doc)) {
if (/^func:/.test(filter.result)) if (/^func:/.test(filter.result))
var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line); var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line);
@@ -2613,7 +2613,7 @@ Buffer.addPageInfoSection("e", "Search Engines", function* (verbose) {
let n = 1; let n = 1;
let nEngines = 0; let nEngines = 0;
for (let { document: doc } of values(this.allFrames())) { for (let { document: doc } of this.allFrames()) {
let engines = DOM("link[href][rel=search][type='application/opensearchdescription+xml']", doc); let engines = DOM("link[href][rel=search][type='application/opensearchdescription+xml']", doc);
nEngines += engines.length; nEngines += engines.length;

View File

@@ -576,7 +576,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
_("command.wontReplace", name)); _("command.wontReplace", name));
} }
for (let name of values(names)) { for (let name of names) {
ex.__defineGetter__(name, function () this._run(name)); ex.__defineGetter__(name, function () this._run(name));
if (name in this._map && !this._map[name].isPlaceholder) if (name in this._map && !this._map[name].isPlaceholder)
this.remove(name); this.remove(name);
@@ -587,7 +587,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
memoize(this._map, name, () => commands.Command(specs, description, action, extra)); memoize(this._map, name, () => commands.Command(specs, description, action, extra));
if (!extra.hidden) if (!extra.hidden)
memoize(this._list, this._list.length, closure); memoize(this._list, this._list.length, closure);
for (let alias of values(names.slice(1))) for (let alias of names.slice(1))
memoize(this._map, alias, closure); memoize(this._map, alias, closure);
return name; return name;
@@ -647,7 +647,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
let cmd = this.get(name); let cmd = this.get(name);
this._list = this._list.filter(c => c !== cmd); this._list = this._list.filter(c => c !== cmd);
for (let name of values(cmd.names)) for (let name of cmd.names)
delete this._map[name]; delete this._map[name];
} }
}); });

View File

@@ -35,7 +35,7 @@ var Group = Class("Group", {
modifiable: true, modifiable: true,
cleanup: function cleanup(reason) { cleanup: function cleanup(reason) {
for (let hive of values(this.hives)) for (let hive of this.hives)
util.trapErrors("cleanup", hive); util.trapErrors("cleanup", hive);
this.hives = []; this.hives = [];
@@ -46,7 +46,7 @@ var Group = Class("Group", {
this.children.splice(0).forEach(this.contexts.bound.removeGroup); this.children.splice(0).forEach(this.contexts.bound.removeGroup);
}, },
destroy: function destroy(reason) { destroy: function destroy(reason) {
for (let hive of values(this.hives)) for (let hive of this.hives)
util.trapErrors("destroy", hive); util.trapErrors("destroy", hive);
if (reason != "shutdown") if (reason != "shutdown")
@@ -154,7 +154,7 @@ var Contexts = Module("contexts", {
}, },
destroy: function () { destroy: function () {
for (let hive of values(this.groupList.slice())) for (let hive of this.groupList.slice())
util.trapErrors("destroy", hive, "shutdown"); util.trapErrors("destroy", hive, "shutdown");
for (let plugin of values(this.modules.plugins.contexts)) { for (let plugin of values(this.modules.plugins.contexts)) {
@@ -706,7 +706,7 @@ var Contexts = Module("contexts", {
arguments: [group.name], arguments: [group.name],
ignoreDefaults: true ignoreDefaults: true
} }
for (group of values(contexts.initializedGroups())) for (group of contexts.initializedGroups())
if (!group.builtin && group.persist) if (!group.builtin && group.persist)
].concat([{ command: this.name, arguments: ["user"] }]) ].concat([{ command: this.name, arguments: ["user"] }])
}); });

View File

@@ -1048,7 +1048,7 @@ var DOM = Class("DOM", {
this.code_nativeKey = {}; this.code_nativeKey = {};
for (let list of values(this.keyTable)) for (let list of values(this.keyTable))
for (let v of values(list)) { for (let v of list) {
if (v.length == 1) if (v.length == 1)
v = v.toLowerCase(); v = v.toLowerCase();
this.key_key[v.toLowerCase()] = v; this.key_key[v.toLowerCase()] = v;
@@ -1477,7 +1477,7 @@ var DOM = Class("DOM", {
*/ */
compileMatcher: function compileMatcher(list) { compileMatcher: function compileMatcher(list) {
let xpath = [], css = []; let xpath = [], css = [];
for (let elem of values(list)) for (let elem of list)
if (/^xpath:/.test(elem)) if (/^xpath:/.test(elem))
xpath.push(elem.substr(6)); xpath.push(elem.substr(6));
else else

View File

@@ -357,7 +357,7 @@ var DownloadList = Class("DownloadList",
let active = downloads.filter(d => d.active); let active = downloads.filter(d => d.active);
let self = Object.create(this); let self = Object.create(this);
for (let prop of values(["currentBytes", "totalBytes", "speed", "timeRemaining"])) for (let prop of ["currentBytes", "totalBytes", "speed", "timeRemaining"])
this[prop] = active.reduce((acc, dl) => dl[prop] + acc, 0); this[prop] = active.reduce((acc, dl) => dl[prop] + acc, 0);
this.hasProgress = active.every(d => d.hasProgress); this.hasProgress = active.every(d => d.hasProgress);
@@ -368,7 +368,7 @@ var DownloadList = Class("DownloadList",
if (active.length) if (active.length)
this.nodes.total.textContent = _("download.nActive", active.length); this.nodes.total.textContent = _("download.nActive", active.length);
else for (let key of values(["total", "percent", "speed", "time"])) else for (let key of ["total", "percent", "speed", "time"])
this.nodes[key].textContent = ""; this.nodes[key].textContent = "";
if (this.shouldSort("complete", "size", "speed", "time")) if (this.shouldSort("complete", "size", "speed", "time"))

View File

@@ -52,7 +52,7 @@ var HelpBuilder = Class("HelpBuilder", {
// Find the tags in the document. // Find the tags in the document.
addTags: function addTags(file, doc) { addTags: function addTags(file, doc) {
for (let elem of DOM.XPath("//@tag|//dactyl:tags/text()|//dactyl:tag/text()", doc)) for (let elem of DOM.XPath("//@tag|//dactyl:tags/text()|//dactyl:tag/text()", doc))
for (let tag of values((elem.value || elem.textContent).split(/\s+/))) for (let tag of (elem.value || elem.textContent).split(/\s+/))
this.tags[tag] = file; this.tags[tag] = file;
}, },
@@ -61,7 +61,7 @@ var HelpBuilder = Class("HelpBuilder", {
// Find help and overlay files with the given name. // Find help and overlay files with the given name.
findHelpFile: function findHelpFile(file) { findHelpFile: function findHelpFile(file) {
let result = []; let result = [];
for (let base of values(this.bases)) { for (let base of this.bases) {
let url = [base, file, ".xml"].join(""); let url = [base, file, ".xml"].join("");
let res = util.httpGet(url, { quiet: true }); let res = util.httpGet(url, { quiet: true });
if (res) { if (res) {
@@ -211,7 +211,7 @@ var Help = Module("Help", {
flush: function flush(entries, time) { flush: function flush(entries, time) {
cache.flushEntry("help.json", time); cache.flushEntry("help.json", time);
for (let entry of values(Array.concat(entries || []))) for (let entry of Array.concat(entries || []))
cache.flushEntry(entry, time); cache.flushEntry(entry, time);
}, },

View File

@@ -97,7 +97,7 @@ var IO = Module("io", {
dactyl.echomsg(_("io.searchingFor", JSON.stringify(paths.join(" ")), modules.options.get("runtimepath").stringValue), 2); dactyl.echomsg(_("io.searchingFor", JSON.stringify(paths.join(" ")), modules.options.get("runtimepath").stringValue), 2);
outer: outer:
for (let dir of values(dirs)) { for (let dir of dirs) {
for (let path of paths) { for (let path of paths) {
let file = dir.child(path); let file = dir.child(path);
@@ -627,7 +627,7 @@ var IO = Module("io", {
} }
else { else {
let dirs = modules.options.get("cdpath").files; let dirs = modules.options.get("cdpath").files;
for (let dir of values(dirs)) { for (let dir of dirs) {
dir = dir.child(arg); dir = dir.child(arg);
if (dir.exists() && dir.isDirectory() && dir.isReadable()) { if (dir.exists() && dir.isDirectory() && dir.isReadable()) {

View File

@@ -288,7 +288,7 @@ overlay.overlayWindow(Object.keys(config.overlays),
if (seen.add(module.className)) if (seen.add(module.className))
throw Error("Module dependency loop."); throw Error("Module dependency loop.");
for (let dep of values(module.requires)) for (let dep of module.requires)
this.loadModule(Module.constructors[dep], module.className); this.loadModule(Module.constructors[dep], module.className);
defineModule.loadLog.push( defineModule.loadLog.push(

View File

@@ -489,7 +489,7 @@ var Option = Class("Option", {
get charlist() this.stringlist, get charlist() this.stringlist,
regexplist: function regexplist(k, default_=null) { regexplist: function regexplist(k, default_=null) {
for (let re of values(this.value)) for (let re of this.value)
if ((re.test || re).call(re, k)) if ((re.test || re).call(re, k))
return re.result; return re.result;
return default_; return default_;
@@ -814,7 +814,7 @@ var Option = Class("Option", {
update(BooleanOption.prototype, { update(BooleanOption.prototype, {
names: Class.Memoize(function () names: Class.Memoize(function ()
Ary.flatten([[name, "no" + name] for (name of values(this.realNames))])) Ary.flatten([[name, "no" + name] for (name of this.realNames)]))
}); });
var OptionHive = Class("OptionHive", Contexts.Hive, { var OptionHive = Class("OptionHive", Contexts.Hive, {
@@ -966,7 +966,7 @@ var Options = Module("options", {
memoize(this._optionMap, name, memoize(this._optionMap, name,
function () Option.types[type](modules, names, description, defaultValue, extraInfo)); function () Option.types[type](modules, names, description, defaultValue, extraInfo));
for (let alias of values(names.slice(1))) for (let alias of names.slice(1))
memoize(this._optionMap, alias, closure); memoize(this._optionMap, alias, closure);
if (extraInfo.setter && (!extraInfo.scope || extraInfo.scope & Option.SCOPE_GLOBAL)) if (extraInfo.setter && (!extraInfo.scope || extraInfo.scope & Option.SCOPE_GLOBAL))
@@ -1099,7 +1099,7 @@ var Options = Module("options", {
remove: function remove(name) { remove: function remove(name) {
let opt = this.get(name); let opt = this.get(name);
this._options = this._options.filter(o => o != opt); this._options = this._options.filter(o => o != opt);
for (let name of values(opt.names)) for (let name of opt.names)
delete this._optionMap[name]; delete this._optionMap[name];
}, },
@@ -1167,7 +1167,7 @@ var Options = Module("options", {
modules.commandline.input(_("pref.prompt.resetAll", config.host) + " ", modules.commandline.input(_("pref.prompt.resetAll", config.host) + " ",
function (resp) { function (resp) {
if (resp == "yes") if (resp == "yes")
for (let pref of values(prefs.getNames())) for (let pref of prefs.getNames())
prefs.reset(pref); prefs.reset(pref);
}, },
{ promptHighlight: "WarningMsg" }); { promptHighlight: "WarningMsg" });
@@ -1315,7 +1315,7 @@ var Options = Module("options", {
// Fill in the current values if we're removing // Fill in the current values if we're removing
if (opt.operator == "-" && isArray(opt.values)) { if (opt.operator == "-" && isArray(opt.values)) {
let have = new RealSet(i.text for (i of values(context.allItems.items))); let have = new RealSet(i.text for (i of context.allItems.items));
context = context.fork("current-values", 0); context = context.fork("current-values", 0);
context.anchored = optcontext.anchored; context.anchored = optcontext.anchored;
context.maxItems = optcontext.maxItems; context.maxItems = optcontext.maxItems;
@@ -1582,7 +1582,7 @@ var Options = Module("options", {
description: "Options containing hostname data", description: "Options containing hostname data",
action: function sanitize_action(timespan, host) { action: function sanitize_action(timespan, host) {
if (host) if (host)
for (let opt of values(modules.options._options)) for (let opt of modules.options._options)
if (timespan.contains(opt.lastSet * 1000) && opt.domains) if (timespan.contains(opt.lastSet * 1000) && opt.domains)
try { try {
opt.value = opt.filterDomain(host, opt.value); opt.value = opt.filterDomain(host, opt.value);

View File

@@ -57,7 +57,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
if (this == prefs) { if (this == prefs) {
if (~["uninstall", "disable"].indexOf(reason)) { if (~["uninstall", "disable"].indexOf(reason)) {
for (let name of values(this.branches.saved.getNames())) for (let name of this.branches.saved.getNames())
this.safeReset(name, null, true); this.safeReset(name, null, true);
this.branches.original.resetBranch(); this.branches.original.resetBranch();

View File

@@ -20,7 +20,7 @@ var Binding = Class("Binding", {
Object.defineProperties(node, this.constructor.properties); Object.defineProperties(node, this.constructor.properties);
for (let [event, handler] of values(this.constructor.events)) for (let [event, handler] of this.constructor.events)
node.addEventListener(event, util.wrapCallback(handler, true), false); node.addEventListener(event, util.wrapCallback(handler, true), false);
}, },
@@ -74,7 +74,7 @@ var Binding = Class("Binding", {
for (let prop of properties(obj)) { for (let prop of properties(obj)) {
let desc = Object.getOwnPropertyDescriptor(obj, prop); let desc = Object.getOwnPropertyDescriptor(obj, prop);
if (desc.enumerable) { if (desc.enumerable) {
for (let k of values(["get", "set", "value"])) for (let k of ["get", "set", "value"])
if (typeof desc[k] === "function") if (typeof desc[k] === "function")
desc[k] = this.bind(desc[k]); desc[k] = this.bind(desc[k]);
res[prop] = desc; res[prop] = desc;

View File

@@ -1173,7 +1173,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
"dactyl-cleanup-modules": function cleanupModules(subject, reason) { "dactyl-cleanup-modules": function cleanupModules(subject, reason) {
defineModule.loadLog.push("dactyl: util: observe: dactyl-cleanup-modules " + reason); defineModule.loadLog.push("dactyl: util: observe: dactyl-cleanup-modules " + reason);
for (let module of values(defineModule.modules)) for (let module of defineModule.modules)
if (module.cleanup) { if (module.cleanup) {
util.dump("cleanup: " + module.constructor.className); util.dump("cleanup: " + module.constructor.className);
util.trapErrors(module.cleanup, module, reason); util.trapErrors(module.cleanup, module, reason);