mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-04 23:44:11 +01:00
Fix iteration over whacky Map Iterators.
This commit is contained in:
@@ -1634,7 +1634,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
if (args["+purgecaches"])
|
||||
cache.flush();
|
||||
|
||||
util.delay(function () { util.rehash(args) });
|
||||
util.delay(() => { util.rehash(args) });
|
||||
},
|
||||
{
|
||||
argCount: "0", // FIXME
|
||||
|
||||
@@ -1409,10 +1409,6 @@ function iter(obj, iface) {
|
||||
if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
|
||||
return iter(obj).map(item => item.QueryInterface(iface));
|
||||
|
||||
if (isinstance(obj, ["Map Iterator"]))
|
||||
// This is stupid.
|
||||
obj = { __iterator__: (function () this).bind(obj) };
|
||||
|
||||
let args = arguments;
|
||||
let res = Iterator(obj);
|
||||
|
||||
@@ -1424,6 +1420,17 @@ function iter(obj, iface) {
|
||||
})();
|
||||
else if (isinstance(obj, ["Iterator", "Generator"]))
|
||||
;
|
||||
else if (isinstance(obj, ["Map Iterator"]))
|
||||
// This is stupid.
|
||||
res = (function () {
|
||||
for (;;) {
|
||||
let { value, done } = obj.next();
|
||||
if (done)
|
||||
return;
|
||||
|
||||
yield value;
|
||||
}
|
||||
})();
|
||||
else if (isinstance(obj, ["Map"]))
|
||||
// This is stupid.
|
||||
res = (r for (r of obj));
|
||||
@@ -1603,6 +1610,7 @@ const Iter = Class("Iter", {
|
||||
|
||||
__iterator__: function () this.iter
|
||||
});
|
||||
iter.Iter = Iter;
|
||||
|
||||
/**
|
||||
* Array utility methods.
|
||||
|
||||
Reference in New Issue
Block a user