1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-14 14:15:47 +01:00

Replace expression closures (getters).

Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
Doug Kearns
2015-05-27 04:42:30 +10:00
parent ce82387cdd
commit 6e8040286a
48 changed files with 808 additions and 532 deletions

View File

@@ -72,16 +72,16 @@ var Option = Class("Option", {
*/
description: Messages.Localized(""),
get helpTag() "'" + this.name + "'",
get helpTag() { return "'" + this.name + "'"; },
initValue: function initValue() {
util.trapErrors(() => { this.value = this.value; });
},
get isDefault() this.stringValue === this.stringDefaultValue,
get isDefault() { return this.stringValue === this.stringDefaultValue; },
/** @property {value} The value to reset this option to at cleanup time. */
get cleanupValue() options.cleanupPrefs.get(this.name),
get cleanupValue() { return options.cleanupPrefs.get(this.name); },
set cleanupValue(value) {
if (options.cleanupPrefs.get(this.name) == null)
options.cleanupPrefs.set(this.name, value);
@@ -194,14 +194,14 @@ var Option = Class("Option", {
* or if no local value is set, this is equal to the
* (@link #globalValue).
*/
get value() this.get(),
set value(val) this.set(val),
get value() { return this.get(); },
set value(val) { this.set(val); },
get stringValue() this.stringify(this.value),
set stringValue(value) this.value = this.parse(value),
get stringValue() { return this.stringify(this.value); },
set stringValue(value) { this.value = this.parse(value); },
get stringDefaultValue() this.stringify(this.defaultValue),
set stringDefaultValue(val) this.defaultValue = this.parse(val),
get stringDefaultValue() { return this.stringify(this.defaultValue); },
set stringDefaultValue(val) { this.defaultValue = this.parse(val); },
getKey: function getKey(key) undefined,
@@ -411,8 +411,11 @@ var Option = Class("Option", {
* @property {number} Returns the timestamp when the option's value was
* last changed.
*/
get lastSet() options.store.get(this.name).time,
set lastSet(val) { options.store.set(this.name, { value: this.globalValue, time: Date.now() }); },
get lastSet() { return options.store.get(this.name).time; },
set lastSet(val) {
options.store.set(this.name,
{ value: this.globalValue, time: Date.now() });
},
/**
* @property {nsIFile} The script in which this option was last set. null
@@ -486,7 +489,7 @@ var Option = Class("Option", {
getKey: {
stringlist: function stringlist(k) this.value.indexOf(k) >= 0,
get charlist() this.stringlist,
get charlist() { return this.stringlist; },
regexplist: function regexplist(k, default_=null) {
for (let re of this.value)
@@ -494,14 +497,14 @@ var Option = Class("Option", {
return re.result;
return default_;
},
get regexpmap() this.regexplist,
get sitelist() this.regexplist,
get sitemap() this.regexplist
get regexpmap() { return this.regexplist; },
get sitelist() { return this.regexplist; },
get sitemap() { return this.regexplist; }
},
domains: {
sitelist: function (vals) Ary.compact(vals.map(site => util.getHost(site.filter))),
get sitemap() this.sitelist
get sitemap() { return this.sitelist; }
},
stringify: {
@@ -512,9 +515,9 @@ var Option = Class("Option", {
stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v, /:/) for ([k, v] of iter(vals))].join(","),
regexplist: function (vals) vals.join(","),
get regexpmap() this.regexplist,
get sitelist() this.regexplist,
get sitemap() this.regexplist
get regexpmap() { return this.regexplist; },
get sitelist() { return this.regexplist; },
get sitemap() { return this.regexplist; }
},
parse: {
@@ -580,7 +583,7 @@ var Option = Class("Option", {
testValues: {
regexpmap: function regexpmap(vals, validator) vals.every(re => validator(re.result)),
get sitemap() this.regexpmap,
get sitemap() { return this.regexpmap; },
stringlist: function stringlist(vals, validator) vals.every(validator, this),
stringmap: function stringmap(vals, validator) values(vals).every(validator, this)
},
@@ -717,11 +720,11 @@ var Option = Class("Option", {
}
return null;
},
get charlist() this.stringlist,
get regexplist() this.stringlist,
get regexpmap() this.stringlist,
get sitelist() this.stringlist,
get sitemap() this.stringlist
get charlist() { return this.stringlist; },
get regexplist() { return this.stringlist; },
get regexpmap() { return this.stringlist; },
get sitelist() { return this.stringlist; },
get sitemap() { return this.stringlist; }
},
validIf: function validIf(test, error) {
@@ -1104,7 +1107,7 @@ var Options = Module("options", {
},
/** @property {Object} The options store. */
get store() storage.options
get store() { return storage.options; }
}, {
}, {
commands: function initCommands(dactyl, modules, window) {