mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-19 22:57:59 +01:00
Convert expression closures to arrow syntax.
This commit is contained in:
@@ -57,7 +57,7 @@ var JavaScript = Module("javascript", {
|
||||
|
||||
newContext: function () this.modules.newContext(this.modules.userContext, true, "Dactyl JS Temp Context"),
|
||||
|
||||
completers: Class.Memoize(function () Object.create(JavaScript.completers)),
|
||||
completers: Class.Memoize(() => Object.create(JavaScript.completers)),
|
||||
|
||||
// Some object members are only accessible as function calls
|
||||
getKey: function (obj, key) {
|
||||
@@ -273,7 +273,7 @@ var JavaScript = Module("javascript", {
|
||||
|
||||
// Don't eval any function calls unless the user presses tab.
|
||||
_checkFunction: function (start, end, key) {
|
||||
let res = this._functions.some(function (idx) idx >= start && idx < end);
|
||||
let res = this._functions.some(idx => idx >= start && idx < end);
|
||||
if (!res || this.context.tabPressed || key in this.cache.evalled)
|
||||
return false;
|
||||
this.context.waitingForTab = true;
|
||||
@@ -345,11 +345,11 @@ var JavaScript = Module("javascript", {
|
||||
let prefix = last != null ? key : "";
|
||||
|
||||
if (last == null) // We're not looking for a quoted string, so filter out anything that's not a valid identifier
|
||||
base.filters.push(function (item) /^[a-zA-Z_$][\w$]*$/.test(item.text));
|
||||
base.filters.push(item => /^[a-zA-Z_$][\w$]*$/.test(item.text));
|
||||
else {
|
||||
base.quote = [last, function (text) util.escapeString(text, ""), last];
|
||||
base.quote = [last, text => util.escapeString(text, ""), last];
|
||||
if (prefix)
|
||||
base.filters.push(function (item) item.item.indexOf(prefix) === 0);
|
||||
base.filters.push(item => item.item.indexOf(prefix) === 0);
|
||||
}
|
||||
|
||||
if (!compl) {
|
||||
@@ -371,7 +371,7 @@ var JavaScript = Module("javascript", {
|
||||
};
|
||||
|
||||
base.keys = {
|
||||
text: prefix ? function (text) text.substr(prefix.length) : util.identity,
|
||||
text: prefix ? text => text.substr(prefix.length) : util.identity,
|
||||
description: function (item) self.getKey(this.obj, item),
|
||||
key: function (item) {
|
||||
if (!isNaN(key))
|
||||
@@ -389,7 +389,7 @@ var JavaScript = Module("javascript", {
|
||||
objects.forEach(function (obj) {
|
||||
let context = base.fork(obj[1]);
|
||||
context.title = [obj[1]];
|
||||
context.keys.obj = function () obj[0];
|
||||
context.keys.obj = () => obj[0];
|
||||
context.key = obj[1] + last;
|
||||
if (obj[0] == this.cache.evalContext)
|
||||
context.regenerate = true;
|
||||
@@ -397,8 +397,8 @@ var JavaScript = Module("javascript", {
|
||||
obj.ctxt_t = context.fork("toplevel");
|
||||
if (!compl) {
|
||||
obj.ctxt_p = context.fork("prototypes");
|
||||
obj.ctxt_t.generate = function () self.objectKeys(obj[0], true);
|
||||
obj.ctxt_p.generate = function () self.objectKeys(obj[0], false);
|
||||
obj.ctxt_t.generate = () => self.objectKeys(obj[0], true);
|
||||
obj.ctxt_p.generate = () => self.objectKeys(obj[0], false);
|
||||
}
|
||||
}, this);
|
||||
|
||||
@@ -563,7 +563,7 @@ var JavaScript = Module("javascript", {
|
||||
for (let [i, idx] in Iterator(this._get(-2).comma)) {
|
||||
let arg = this._str.substring(prev + 1, idx);
|
||||
prev = idx;
|
||||
memoize(args, i, function () self.evalled(arg));
|
||||
memoize(args, i, () => self.evalled(arg));
|
||||
}
|
||||
let key = this._getKey();
|
||||
args.push(key + string);
|
||||
@@ -641,7 +641,7 @@ var JavaScript = Module("javascript", {
|
||||
].concat([k.substr(6) for (k in keys(Ci)) if (/^nsIDOM/.test(k))])
|
||||
.concat([k.substr(3) for (k in keys(Ci)) if (/^nsI/.test(k))])
|
||||
.concat(this.magicalNames)
|
||||
.filter(function (k) k in self.window))),
|
||||
.filter(k => k in self.window))),
|
||||
|
||||
}, {
|
||||
EVAL_TMP: "__dactyl_eval_tmp",
|
||||
@@ -775,7 +775,7 @@ var JavaScript = Module("javascript", {
|
||||
this.js.globals = [
|
||||
[this.context, /*L*/"REPL Variables"],
|
||||
[context, /*L*/"REPL Global"]
|
||||
].concat(this.js.globals.filter(function ([global]) isPrototypeOf.call(global, context)));
|
||||
].concat(this.js.globals.filter(([global]) => isPrototypeOf.call(global, context)));
|
||||
|
||||
if (!isPrototypeOf.call(modules.jsmodules, context))
|
||||
this.js.toplevel = context;
|
||||
@@ -783,7 +783,7 @@ var JavaScript = Module("javascript", {
|
||||
if (!isPrototypeOf.call(window, context))
|
||||
this.js.window = context;
|
||||
|
||||
if (this.js.globals.slice(2).some(function ([global]) global === context))
|
||||
if (this.js.globals.slice(2).some(([global]) => global === context))
|
||||
this.js.globals.splice(1);
|
||||
|
||||
this.repl = REPL(this.context);
|
||||
|
||||
Reference in New Issue
Block a user