mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-13 09:25:44 +01:00
Replace expression closures (function declarations).
Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
@@ -409,7 +409,9 @@ var Addons = Module("addons", {
|
||||
// TODO: handle extension dependencies
|
||||
values(actions).forEach(function (command) {
|
||||
let perm = command.perm && AddonManager["PERM_CAN_" + command.perm.toUpperCase()];
|
||||
function ok(addon) (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon));
|
||||
function ok(addon) {
|
||||
return (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon));
|
||||
}
|
||||
|
||||
commands.add(Array.concat(command.name),
|
||||
command.description,
|
||||
|
||||
@@ -44,7 +44,9 @@ function lazyRequire(module, names, target) {
|
||||
let jsmodules = { lazyRequire: lazyRequire };
|
||||
jsmodules.jsmodules = jsmodules;
|
||||
|
||||
function toString() "[module-global " + this.NAME + "]";
|
||||
function toString() {
|
||||
return "[module-global " + this.NAME + "]";
|
||||
}
|
||||
|
||||
function objToString(obj) {
|
||||
try {
|
||||
@@ -406,7 +408,7 @@ function keys(obj) {
|
||||
* @param {object} obj The object to inspect.
|
||||
* @returns {Iter}
|
||||
*/
|
||||
function values(obj) {
|
||||
function values(obj) {
|
||||
if (isinstance(obj, ["Map"]))
|
||||
return iter(obj.values());
|
||||
|
||||
@@ -582,7 +584,9 @@ function curry(fn, length, self, acc) {
|
||||
return fn;
|
||||
|
||||
// Close over function with 'this'
|
||||
function close(self, fn) (...args) => fn.apply(self, args);
|
||||
function close(self, fn) {
|
||||
return (...args) => fn.apply(self, args);
|
||||
}
|
||||
|
||||
if (acc == null)
|
||||
acc = [];
|
||||
@@ -668,7 +672,9 @@ function isinstance(object, interfaces) {
|
||||
/**
|
||||
* Returns true if obj is a non-null object.
|
||||
*/
|
||||
function isObject(obj) typeof obj === "object" && obj != null || obj instanceof Ci.nsISupports;
|
||||
function isObject(obj) {
|
||||
return typeof obj === "object" && obj != null || obj instanceof Ci.nsISupports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if its sole argument is an
|
||||
@@ -678,7 +684,9 @@ function isObject(obj) typeof obj === "object" && obj != null || obj instanceof
|
||||
*/
|
||||
var isArray =
|
||||
// This is bloody stupid.
|
||||
function isArray(val) Array.isArray(val) || val && val.constructor && val.constructor.name === "Array";
|
||||
function isArray(val) {
|
||||
return Array.isArray(val) || val && val.constructor && val.constructor.name === "Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if its sole argument is an
|
||||
@@ -686,7 +694,9 @@ var isArray =
|
||||
* functions containing the 'yield' statement and generator
|
||||
* statements such as (x for (x in obj)).
|
||||
*/
|
||||
function isGenerator(val) objToString(val) == "[object Generator]";
|
||||
function isGenerator(val) {
|
||||
return objToString(val) == "[object Generator]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if its sole argument is a String,
|
||||
@@ -695,13 +705,17 @@ function isGenerator(val) objToString(val) == "[object Generator]";
|
||||
* namespace, or execution context, which is not the case when
|
||||
* using (obj instanceof String) or (typeof obj == "string").
|
||||
*/
|
||||
function isString(val) objToString(val) == "[object String]";
|
||||
function isString(val) {
|
||||
return objToString(val) == "[object String]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if and only if its sole argument may be called
|
||||
* as a function. This includes classes and function objects.
|
||||
*/
|
||||
function callable(val) typeof val === "function" && !(val instanceof Ci.nsIDOMElement);
|
||||
function callable(val) {
|
||||
return typeof val === "function" && !(val instanceof Ci.nsIDOMElement);
|
||||
}
|
||||
|
||||
function call(fn, self, ...args) {
|
||||
fn.apply(self, args);
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ["require"];
|
||||
|
||||
function create(proto) Object.create(proto);
|
||||
function create(proto) {
|
||||
return Object.create(proto);
|
||||
}
|
||||
|
||||
this["import"] = function import_(obj) {
|
||||
let res = {};
|
||||
@@ -20,6 +22,8 @@ if (typeof TextEncoder == "undefined")
|
||||
|
||||
// Deal with subScriptLoader prepending crap to loaded URLs
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
function loadSubScript() Services.scriptloader.loadSubScript.apply(null, arguments);
|
||||
function loadSubScript() {
|
||||
return Services.scriptloader.loadSubScript.apply(null, arguments);
|
||||
}
|
||||
|
||||
// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript:
|
||||
|
||||
@@ -515,11 +515,15 @@ var Buffer = Module("Buffer", {
|
||||
for (let elem of iter(elems))
|
||||
yield elem;
|
||||
|
||||
function a(regexp, elem) regexp.test(elem.textContent) === regexp.result ||
|
||||
Array.some(elem.childNodes,
|
||||
child => (regexp.test(child.alt) === regexp.result));
|
||||
function a(regexp, elem) {
|
||||
return regexp.test(elem.textContent) === regexp.result ||
|
||||
Array.some(elem.childNodes,
|
||||
child => (regexp.test(child.alt) === regexp.result));
|
||||
}
|
||||
|
||||
function b(regexp, elem) regexp.test(elem.title) === regexp.result;
|
||||
function b(regexp, elem) {
|
||||
return regexp.test(elem.title) === regexp.result;
|
||||
}
|
||||
|
||||
let res = Array.filter(frame.document.querySelectorAll(selector),
|
||||
Hints.isVisible);
|
||||
@@ -617,7 +621,9 @@ var Buffer = Module("Buffer", {
|
||||
* viewport.
|
||||
*/
|
||||
resetCaret: function resetCaret() {
|
||||
function visible(range) util.intersection(DOM(range).rect, viewport);
|
||||
function visible(range) {
|
||||
return util.intersection(DOM(range).rect, viewport);
|
||||
}
|
||||
|
||||
function getRanges(rect) {
|
||||
let nodes = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)
|
||||
@@ -2771,9 +2777,12 @@ Buffer.addPageInfoSection("s", "Security", function* (verbose) {
|
||||
return; // For now
|
||||
|
||||
// Modified from Firefox
|
||||
function location(data) Ary.compact([
|
||||
data.city, data.state, data.country
|
||||
]).join(", ");
|
||||
function location(data) {
|
||||
return Ary.compact([data.city,
|
||||
data.state,
|
||||
data.country])
|
||||
.join(", ");
|
||||
}
|
||||
|
||||
switch (statusline.security) {
|
||||
case "secure":
|
||||
|
||||
@@ -767,7 +767,9 @@ var Commands = Module("commands", {
|
||||
return "";
|
||||
}
|
||||
// TODO: allow matching of aliases?
|
||||
function cmds(hive) hive._list.filter(cmd => cmd.name.startsWith(filter || ""))
|
||||
function cmds(hive) {
|
||||
return hive._list.filter(cmd => cmd.name.startsWith(filter || ""));
|
||||
}
|
||||
|
||||
hives = (hives || this.userHives).map(h => [h, cmds(h)])
|
||||
.filter(([h, c]) => c.length);
|
||||
@@ -1401,8 +1403,10 @@ var Commands = Module("commands", {
|
||||
let quote = null;
|
||||
let len = str.length;
|
||||
|
||||
function fixEscapes(str) str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g,
|
||||
(m, n1) => n1 || m);
|
||||
function fixEscapes(str) {
|
||||
return str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g,
|
||||
(m, n1) => n1 || m);
|
||||
}
|
||||
|
||||
// Fix me.
|
||||
if (isString(sep))
|
||||
@@ -1798,8 +1802,10 @@ var Commands = Module("commands", {
|
||||
|
||||
let quote = function quote(q, list, map=Commands.quoteMap) {
|
||||
let re = RegExp("[" + list + "]", "g");
|
||||
function quote(str) (q + String.replace(str, re, $0 => ($0 in map ? map[$0] : ("\\" + $0)))
|
||||
+ q);
|
||||
function quote(str) {
|
||||
return (q + String.replace(str, re, $0 => ($0 in map ? map[$0] : ("\\" + $0)))
|
||||
+ q);
|
||||
}
|
||||
quote.list = list;
|
||||
return quote;
|
||||
};
|
||||
|
||||
@@ -1095,7 +1095,9 @@ var Completion = Module("completion", {
|
||||
contains(item.title, tok)));
|
||||
|
||||
let re = RegExp(tokens.filter(util.identity).map(util.regexp.escape).join("|"), "g");
|
||||
function highlight(item, text, i) process[i].call(this, item, template.highlightRegexp(text, re));
|
||||
function highlight(item, text, i) {
|
||||
return process[i].call(this, item, template.highlightRegexp(text, re));
|
||||
}
|
||||
let process = context.process;
|
||||
context.process = [
|
||||
function process_0(item, text) highlight.call(this, item, item.text, 0),
|
||||
|
||||
@@ -174,10 +174,12 @@ var ConfigBase = Class("ConfigBase", {
|
||||
|
||||
let hl = highlight.set("Find", "");
|
||||
hl.onChange = function () {
|
||||
function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
|
||||
.map(num => ("0" + Number(num).toString(16)).slice(-2))
|
||||
.join("")
|
||||
).slice(0, 7);
|
||||
function hex(val) {
|
||||
return ("#" + util.regexp.iterate(/\d+/g, val)
|
||||
.map(num => ("0" + Number(num).toString(16)).slice(-2))
|
||||
.join("")
|
||||
).slice(0, 7);
|
||||
}
|
||||
|
||||
let elem = services.appShell.hiddenDOMWindow.document.createElement("div");
|
||||
elem.style.cssText = this.cssText;
|
||||
@@ -216,7 +218,9 @@ var ConfigBase = Class("ConfigBase", {
|
||||
*/
|
||||
locales: Class.Memoize(function () {
|
||||
// TODO: Merge with completion.file code.
|
||||
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
||||
function getDir(str) {
|
||||
return str.match(/^(?:.*[\/\\])?/)[0];
|
||||
}
|
||||
|
||||
let uri = "resource://dactyl-locale/";
|
||||
let jar = io.isJarURL(uri);
|
||||
|
||||
@@ -499,12 +499,14 @@ var Contexts = Module("contexts", {
|
||||
bindMacro: function (args, default_, params) {
|
||||
const { dactyl, events, modules } = this.modules;
|
||||
|
||||
function Proxy(obj, key) Class.Property({
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function Proxy_get() process(obj[key]),
|
||||
set: function Proxy_set(val) obj[key] = val
|
||||
})
|
||||
function Proxy(obj, key) {
|
||||
return Class.Property({
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function Proxy_get() process(obj[key]),
|
||||
set: function Proxy_set(val) obj[key] = val
|
||||
});
|
||||
}
|
||||
|
||||
let process = util.identity;
|
||||
|
||||
|
||||
@@ -20,15 +20,17 @@ var XHTML = "http://www.w3.org/1999/xhtml";
|
||||
var XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var NS = "http://vimperator.org/namespaces/liberator";
|
||||
|
||||
function BooleanAttribute(attr) ({
|
||||
get: function (elem) elem.getAttribute(attr) == "true",
|
||||
set: function (elem, val) {
|
||||
if (val === "false" || !val)
|
||||
elem.removeAttribute(attr);
|
||||
else
|
||||
elem.setAttribute(attr, true);
|
||||
}
|
||||
});
|
||||
function BooleanAttribute(attr) {
|
||||
return {
|
||||
get: function (elem) elem.getAttribute(attr) == "true",
|
||||
set: function (elem, val) {
|
||||
if (val === "false" || !val)
|
||||
elem.removeAttribute(attr);
|
||||
else
|
||||
elem.setAttribute(attr, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
@@ -549,7 +551,9 @@ var DOM = Class("DOM", {
|
||||
* @returns {string}
|
||||
*/
|
||||
get xpath() {
|
||||
function quote(val) "'" + val.replace(/[\\']/g, "\\$&") + "'";
|
||||
function quote(val) {
|
||||
return "'" + val.replace(/[\\']/g, "\\$&") + "'";
|
||||
}
|
||||
if (!(this[0] instanceof Ci.nsIDOMElement))
|
||||
return null;
|
||||
|
||||
@@ -1575,7 +1579,9 @@ var DOM = Class("DOM", {
|
||||
|
||||
attr = attr || {};
|
||||
|
||||
function parseNamespace(name) DOM.parseNamespace(name, namespaces);
|
||||
function parseNamespace(name) {
|
||||
return DOM.parseNamespace(name, namespaces);
|
||||
}
|
||||
|
||||
// FIXME: Surely we can do better.
|
||||
for (var key in attr) {
|
||||
@@ -1652,7 +1658,9 @@ var DOM = Class("DOM", {
|
||||
throw Error("No such namespace");
|
||||
}
|
||||
|
||||
function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === "";
|
||||
function isFragment(args) {
|
||||
return !isString(args[0]) || args.length == 0 || args[0] === "";
|
||||
}
|
||||
|
||||
function hasString(args) {
|
||||
return args.some(a => (isString(a) || isFragment(a) && hasString(a)));
|
||||
|
||||
@@ -12,9 +12,14 @@ defineModule("finder", {
|
||||
lazyRequire("buffer", ["Buffer"]);
|
||||
lazyRequire("overlay", ["overlay"]);
|
||||
|
||||
function id(w) w.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)
|
||||
.outerWindowID;
|
||||
function equals(a, b) id(a) == id(b);
|
||||
function id(w) {
|
||||
return w.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.outerWindowID;
|
||||
}
|
||||
function equals(a, b) {
|
||||
return id(a) == id(b);
|
||||
}
|
||||
|
||||
/** @instance rangefinder */
|
||||
var RangeFinder = Module("rangefinder", {
|
||||
|
||||
@@ -242,7 +242,9 @@ var Help = Module("Help", {
|
||||
let items = modules.completion._runCompleter("help", topic, null, !!consolidated).items;
|
||||
let partialMatch = null;
|
||||
|
||||
function format(item) item.description + "#" + encodeURIComponent(item.text);
|
||||
function format(item) {
|
||||
return item.description + "#" + encodeURIComponent(item.text);
|
||||
}
|
||||
|
||||
for (let item of items) {
|
||||
if (item.text == topic)
|
||||
|
||||
@@ -528,13 +528,15 @@ var IO = Module("io", {
|
||||
else if (input)
|
||||
stdin.write(input);
|
||||
|
||||
function result(status, output) ({
|
||||
__noSuchMethod__: function (meth, args) apply(this.output, meth, args),
|
||||
valueOf: function () this.output,
|
||||
output: output.replace(/^(.*)\n$/, "$1"),
|
||||
returnValue: status,
|
||||
toString: function () this.output
|
||||
});
|
||||
function result(status, output) {
|
||||
return {
|
||||
__noSuchMethod__: function (meth, args) apply(this.output, meth, args),
|
||||
valueOf: function () this.output,
|
||||
output: output.replace(/^(.*)\n$/, "$1"),
|
||||
returnValue: status,
|
||||
toString: function () this.output
|
||||
};
|
||||
}
|
||||
|
||||
function async(status) {
|
||||
let output = stdout.read();
|
||||
@@ -1000,7 +1002,9 @@ unlet s:cpo_save
|
||||
context.advance(4);
|
||||
|
||||
// dir == "" is expanded inside readDirectory to the current dir
|
||||
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
|
||||
function getDir(str) {
|
||||
return str.match(/^(?:.*[\/\\])?/)[0];
|
||||
}
|
||||
dir = getDir(dir || context.filter);
|
||||
|
||||
let file = util.getFile(dir);
|
||||
|
||||
@@ -382,7 +382,10 @@ var JavaScript = Module("javascript", {
|
||||
}
|
||||
|
||||
// We've already listed anchored matches, so don't list them again here.
|
||||
function unanchored(item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter);
|
||||
function unanchored(item) {
|
||||
return util.compareIgnoreCase(item.text.substr(0, this.filter.length),
|
||||
this.filter);
|
||||
}
|
||||
|
||||
objects.forEach(function (obj) {
|
||||
let context = base.fork(obj[1]);
|
||||
@@ -856,7 +859,9 @@ var JavaScript = Module("javascript", {
|
||||
mappings: function initMappings(dactyl, modules, window) {
|
||||
const { mappings, modes } = modules;
|
||||
|
||||
function bind(...args) apply(mappings, "add", [[modes.REPL]].concat(args))
|
||||
function bind(...args) {
|
||||
return apply(mappings, "add", [[modes.REPL]].concat(args));
|
||||
}
|
||||
|
||||
bind(["<Return>"], "Accept the current input",
|
||||
function ({ self }) { self.accept(); });
|
||||
|
||||
@@ -106,29 +106,33 @@ var Messages = Module("messages", {
|
||||
let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules;
|
||||
file = io.File(file);
|
||||
|
||||
function properties(base, iter_, prop="description") iter(function* _properties() {
|
||||
function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&");
|
||||
|
||||
for (var obj of iter_) {
|
||||
if (!obj.hive || obj.hive.name !== "user") {
|
||||
yield key(prop) + " = " + obj[prop];
|
||||
|
||||
if (iter_.values) {
|
||||
let iter_ = isArray(obj.values) ? obj.values
|
||||
: iter(obj.values);
|
||||
|
||||
for (let [k, v] of iter_)
|
||||
yield key("values", k) + " = " + v;
|
||||
}
|
||||
|
||||
for (let opt of values(obj.options))
|
||||
yield key("options", opt.names[0]) + " = " + opt.description;
|
||||
|
||||
if (obj.deprecated)
|
||||
yield key("deprecated") + " = " + obj.deprecated;
|
||||
function properties(base, iter_, prop="description") {
|
||||
return iter(function* _properties() {
|
||||
function key(...args) {
|
||||
return [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&");
|
||||
}
|
||||
}
|
||||
}()).toArray();
|
||||
|
||||
for (var obj of iter_) {
|
||||
if (!obj.hive || obj.hive.name !== "user") {
|
||||
yield key(prop) + " = " + obj[prop];
|
||||
|
||||
if (iter_.values) {
|
||||
let iter_ = isArray(obj.values) ? obj.values
|
||||
: iter(obj.values);
|
||||
|
||||
for (let [k, v] of iter_)
|
||||
yield key("values", k) + " = " + v;
|
||||
}
|
||||
|
||||
for (let opt of values(obj.options))
|
||||
yield key("options", opt.names[0]) + " = " + opt.description;
|
||||
|
||||
if (obj.deprecated)
|
||||
yield key("deprecated") + " = " + obj.deprecated;
|
||||
}
|
||||
}
|
||||
}()).toArray();
|
||||
}
|
||||
|
||||
file.write(
|
||||
Ary(commands.allHives.map(h => properties("command", h)))
|
||||
@@ -161,7 +165,9 @@ var Messages = Module("messages", {
|
||||
get: function get() {
|
||||
let value = this[_prop];
|
||||
|
||||
function getter(key, default_) function getter() messages.get([name, key].join("."), default_);
|
||||
function getter(key, default_) {
|
||||
return function getter() messages.get([name, key].join("."), default_);
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
var name = [this.constructor.className.toLowerCase(),
|
||||
|
||||
@@ -1337,9 +1337,11 @@ var Options = Module("options", {
|
||||
function (args) {
|
||||
let globalVariables = dactyl._globalVariables;
|
||||
args = (args[0] || "").trim();
|
||||
function fmt(value) (typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ") + value;
|
||||
function fmt(value) {
|
||||
return (typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ") + value;
|
||||
}
|
||||
util.assert(!(!args || args == "g:"));
|
||||
|
||||
let matches = args.match(/^([a-z]:)?([\w]+)(?:\s*([-+.])?=\s*(.*)?)?$/);
|
||||
|
||||
@@ -162,10 +162,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
override: true
|
||||
});
|
||||
|
||||
function ourItems(persistent) [
|
||||
item for (item of values(self.itemMap))
|
||||
if (!item.builtin && (!persistent || item.persistent) && item.name !== "all")
|
||||
];
|
||||
function ourItems(persistent) {
|
||||
return [
|
||||
item for (item of values(self.itemMap))
|
||||
if (!item.builtin && (!persistent || item.persistent) && item.name !== "all")
|
||||
];
|
||||
}
|
||||
|
||||
function prefOverlay(branch, persistent, local) {
|
||||
return update(Object.create(local),
|
||||
|
||||
@@ -719,17 +719,21 @@ var File = Class("File", {
|
||||
* @returns {string}
|
||||
*/
|
||||
expandPath: function expandPath(path, relative) {
|
||||
function getenv(name) services.environment.get(name);
|
||||
function getenv(name) {
|
||||
return services.environment.get(name);
|
||||
}
|
||||
|
||||
// expand any $ENV vars - this is naive but so is Vim and we like to be compatible
|
||||
// TODO: Vim does not expand variables set to an empty string (and documents it).
|
||||
// Kris reckons we shouldn't replicate this 'bug'. --djk
|
||||
// TODO: should we be doing this for all paths?
|
||||
// No.
|
||||
function expand(path) path.replace(
|
||||
win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g
|
||||
: /\$(\w+)\b|\${(\w+)}/g,
|
||||
(m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m));
|
||||
function expand(path) {
|
||||
return path.replace(
|
||||
win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g
|
||||
: /\$(\w+)\b|\${(\w+)}/g,
|
||||
(m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m));
|
||||
}
|
||||
path = expand(path);
|
||||
|
||||
// expand ~
|
||||
|
||||
@@ -570,16 +570,18 @@ var Styles = Module("Styles", {
|
||||
Styles.splitContext(context);
|
||||
}
|
||||
|
||||
function nameFlag(filter) ({
|
||||
names: ["-name", "-n"],
|
||||
description: "The name of this stylesheet",
|
||||
type: modules.CommandOption.STRING,
|
||||
completer: function (context, args) {
|
||||
context.keys.text = sheet => sheet.name;
|
||||
context.filters.unshift(({ item }) => item.name);
|
||||
sheets(context, args, filter);
|
||||
}
|
||||
});
|
||||
function nameFlag(filter) {
|
||||
return {
|
||||
names: ["-name", "-n"],
|
||||
description: "The name of this stylesheet",
|
||||
type: modules.CommandOption.STRING,
|
||||
completer: function (context, args) {
|
||||
context.keys.text = sheet => sheet.name;
|
||||
context.filters.unshift(({ item }) => item.name);
|
||||
sheets(context, args, filter);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
commands.add(["sty[le]"],
|
||||
"Add or list user styles",
|
||||
|
||||
@@ -259,17 +259,19 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
let stack = [frame()];
|
||||
stack.__defineGetter__("top", function () this[this.length - 1]);
|
||||
|
||||
function frame() update(
|
||||
function _frame(obj)
|
||||
_frame === stack.top || _frame.valid(obj)
|
||||
? _frame.elements.map(e => callable(e) ? e(obj) : e)
|
||||
.join("")
|
||||
: "",
|
||||
{
|
||||
elements: [],
|
||||
seen: {},
|
||||
valid: function valid(obj) this.elements.every(e => !e.test || e.test(obj))
|
||||
});
|
||||
function frame() {
|
||||
return update(
|
||||
function _frame(obj)
|
||||
_frame === stack.top || _frame.valid(obj)
|
||||
? _frame.elements.map(e => callable(e) ? e(obj) : e)
|
||||
.join("")
|
||||
: "",
|
||||
{
|
||||
elements: [],
|
||||
seen: {},
|
||||
valid: function valid(obj) this.elements.every(e => !e.test || e.test(obj))
|
||||
});
|
||||
}
|
||||
|
||||
let end = 0;
|
||||
for (let match of util.regexp.iterate(/(.*?)%(.)/gy, format)) {
|
||||
@@ -345,17 +347,19 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
if (!keepUnknown)
|
||||
unknown = () => "";
|
||||
|
||||
function frame() update(
|
||||
function _frame(obj)
|
||||
_frame === stack.top || _frame.valid(obj)
|
||||
? _frame.elements.map(e => callable(e) ? e(obj) : e)
|
||||
.join("")
|
||||
: "",
|
||||
{
|
||||
elements: [],
|
||||
seen: new RealSet,
|
||||
valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj)))
|
||||
});
|
||||
function frame() {
|
||||
return update(
|
||||
function _frame(obj)
|
||||
_frame === stack.top || _frame.valid(obj)
|
||||
? _frame.elements.map(e => callable(e) ? e(obj) : e)
|
||||
.join("")
|
||||
: "",
|
||||
{
|
||||
elements: [],
|
||||
seen: new RealSet,
|
||||
valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj)))
|
||||
});
|
||||
}
|
||||
|
||||
let defaults = { lt: "<", gt: ">" };
|
||||
|
||||
@@ -655,8 +659,12 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
* @returns {string}
|
||||
*/
|
||||
formatSeconds: function formatSeconds(seconds) {
|
||||
function pad(n, val) ("0000000" + val).substr(-Math.max(n, String(val).length));
|
||||
function div(num, denom) [Math.floor(num / denom), Math.round(num % denom)];
|
||||
function pad(n, val) {
|
||||
return ("0000000" + val).substr(-Math.max(n, String(val).length));
|
||||
}
|
||||
function div(num, denom) {
|
||||
return [Math.floor(num / denom), Math.round(num % denom)];
|
||||
}
|
||||
let days, hours, minutes;
|
||||
|
||||
[minutes, seconds] = div(Math.round(seconds), 60);
|
||||
|
||||
Reference in New Issue
Block a user