mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-13 05:35:45 +01:00
Make further use of default parameters.
--HG-- extra : rebase_source : ab666bce7ed7e47c8f1e2bc4145f553da990d319
This commit is contained in:
@@ -1094,8 +1094,7 @@ let stub = Class.Property({
|
||||
*/
|
||||
var ErrorBase = Class("ErrorBase", Error, {
|
||||
level: 2,
|
||||
init: function EB_init(message, level) {
|
||||
level = level || 0;
|
||||
init: function EB_init(message, level = 0) {
|
||||
let error = Error(message);
|
||||
update(this, error);
|
||||
this.stack = error.stack;
|
||||
@@ -1269,10 +1268,10 @@ var StructBase = Class("StructBase", Array, {
|
||||
});
|
||||
|
||||
var Timer = Class("Timer", {
|
||||
init: function init(minInterval, maxInterval, callback, self) {
|
||||
init: function init(minInterval, maxInterval, callback, self = this) {
|
||||
this._timer = services.Timer();
|
||||
this.callback = callback;
|
||||
this.self = self || this;
|
||||
this.self = self;
|
||||
this.minInterval = minInterval;
|
||||
this.maxInterval = maxInterval;
|
||||
this.doneAt = 0;
|
||||
|
||||
@@ -784,11 +784,10 @@ var Buffer = Module("Buffer", {
|
||||
* @param {number} count The multiple of 'scroll' lines to scroll.
|
||||
* @optional
|
||||
*/
|
||||
scrollByScrollSize: function scrollByScrollSize(direction, count) {
|
||||
scrollByScrollSize: function scrollByScrollSize(direction, count = 1) {
|
||||
let { options } = this.modules;
|
||||
|
||||
direction = direction ? 1 : -1;
|
||||
count = count || 1;
|
||||
|
||||
if (options["scroll"] > 0)
|
||||
this.scrollVertical("lines", options["scroll"] * direction);
|
||||
|
||||
@@ -155,15 +155,13 @@ var Command = Class("Command", {
|
||||
* @param {Args} args The Args object passed to {@link #action}.
|
||||
* @param {Object} modifiers Any modifiers to be passed to {@link #action}.
|
||||
*/
|
||||
execute: function execute(args, modifiers) {
|
||||
execute: function execute(args, modifiers = {}) {
|
||||
const { dactyl } = this.modules;
|
||||
|
||||
let context = args.context;
|
||||
if (this.deprecated)
|
||||
this.warn(context, "deprecated", _("warn.deprecated", ":" + this.name, this.deprecated));
|
||||
|
||||
modifiers = modifiers || {};
|
||||
|
||||
if (args.count != null && !this.count)
|
||||
throw FailedAssertion(_("command.noCount"));
|
||||
if (args.bang && !this.bang)
|
||||
@@ -543,21 +541,21 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
|
||||
repeat: null,
|
||||
|
||||
/**
|
||||
* Adds a new command to the builtin hive. Accessible only to core
|
||||
* dactyl code. Plugins should use group.commands.add instead.
|
||||
* Adds a new command to the builtin hive. Accessible only to core dactyl
|
||||
* code. Plugins should use group.commands.add instead.
|
||||
*
|
||||
* @param {[string]} specs The names by which this command can be
|
||||
* invoked. The first name specified is the command's canonical
|
||||
* name.
|
||||
* @param {[string]} specs The names by which this command can be invoked.
|
||||
* The first name specified is the command's canonical name.
|
||||
* @param {string} description A description of the command.
|
||||
* @param {function} action The action invoked by this command.
|
||||
* @param {Object} extra An optional extra configuration hash.
|
||||
* @optional
|
||||
* @optional
|
||||
* @param {boolean} replace Replace an existing command of the same name.
|
||||
* @optional
|
||||
*/
|
||||
add: function add(specs, description, action, extra, replace) {
|
||||
add: function add(specs, description, action, extra = {}, replace = false) {
|
||||
const { commands, contexts } = this.modules;
|
||||
|
||||
extra = extra || {};
|
||||
if (!extra.definedAt)
|
||||
extra.definedAt = contexts.getCaller(Components.stack.caller);
|
||||
if (!extra.sourceModule)
|
||||
@@ -594,10 +592,8 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
|
||||
return name;
|
||||
},
|
||||
|
||||
_add: function _add(names, description, action, extra, replace) {
|
||||
_add: function _add(names, description, action, extra = {}, replace = false) {
|
||||
const { contexts } = this.modules;
|
||||
|
||||
extra = extra || {};
|
||||
extra.definedAt = contexts.getCaller(Components.stack.caller.caller);
|
||||
return this.add.apply(this, arguments);
|
||||
},
|
||||
@@ -968,7 +964,7 @@ var Commands = Module("commands", {
|
||||
* Args object.
|
||||
* @returns {Args}
|
||||
*/
|
||||
parseArgs: function parseArgs(str, params) {
|
||||
parseArgs: function parseArgs(str, params = {}) {
|
||||
const self = this;
|
||||
|
||||
function getNextArg(str, _keepQuotes=keepQuotes) {
|
||||
@@ -990,7 +986,7 @@ var Commands = Module("commands", {
|
||||
|
||||
try {
|
||||
|
||||
var { allowUnknownOptions, argCount, complete, extra, hereDoc, literal, options, keepQuotes } = params || {};
|
||||
var { allowUnknownOptions, argCount, complete, extra, hereDoc, literal, options, keepQuotes } = params;
|
||||
|
||||
if (!options)
|
||||
options = [];
|
||||
@@ -1776,8 +1772,7 @@ var Commands = Module("commands", {
|
||||
}
|
||||
});
|
||||
|
||||
let quote = function quote(q, list, map) {
|
||||
map = map || Commands.quoteMap;
|
||||
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);
|
||||
|
||||
@@ -33,10 +33,7 @@ lazyRequire("template", ["template"]);
|
||||
* @constructor
|
||||
*/
|
||||
var CompletionContext = Class("CompletionContext", {
|
||||
init: function cc_init(editor, name, offset) {
|
||||
if (!name)
|
||||
name = "";
|
||||
|
||||
init: function cc_init(editor, name = "", offset = 0) {
|
||||
let self = this;
|
||||
if (editor instanceof this.constructor) {
|
||||
let parent = editor;
|
||||
@@ -68,7 +65,7 @@ var CompletionContext = Class("CompletionContext", {
|
||||
self.__defineGetter__("value", function get_value() this.top.value);
|
||||
|
||||
self.offset = parent.offset;
|
||||
self.advance(offset || 0);
|
||||
self.advance(offset);
|
||||
|
||||
/**
|
||||
* @property {boolean} Specifies that this context is not finished
|
||||
@@ -156,7 +153,7 @@ var CompletionContext = Class("CompletionContext", {
|
||||
* @property {number} This context's offset from the beginning of
|
||||
* {@link #editor}'s value.
|
||||
*/
|
||||
this.offset = offset || 0;
|
||||
this.offset = offset;
|
||||
/**
|
||||
* @property {function} A function which is called when any subcontext
|
||||
* changes its completion list. Only called when
|
||||
|
||||
@@ -241,11 +241,13 @@ var IO = Module("io", {
|
||||
/**
|
||||
* Sets the current working directory.
|
||||
*
|
||||
* @param {string} newDir The new CWD. This may be a relative or
|
||||
* @param {File|string} newDir The new CWD. This may be a relative or
|
||||
* absolute path and is expanded by {@link #expandPath}.
|
||||
* @optional
|
||||
* @default = "~"
|
||||
*/
|
||||
set cwd(newDir) {
|
||||
newDir = newDir && newDir.path || newDir || "~";
|
||||
set cwd(newDir = "~") {
|
||||
newDir = newDir.path || newDir;
|
||||
|
||||
if (newDir == "-") {
|
||||
util.assert(this._oldcwd != null, _("io.noPrevDir"));
|
||||
|
||||
@@ -11,9 +11,9 @@ defineModule("messages", {
|
||||
|
||||
var Messages = Module("messages", {
|
||||
|
||||
init: function init(name) {
|
||||
init: function init(name = "messages") {
|
||||
let self = this;
|
||||
this.name = name || "messages";
|
||||
this.name = name;
|
||||
|
||||
this._ = Class("_", String, {
|
||||
init: function _(message) {
|
||||
@@ -97,10 +97,9 @@ var Messages = Module("messages", {
|
||||
let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules;
|
||||
file = io.File(file);
|
||||
|
||||
function properties(base, iter_, prop) iter(function _properties() {
|
||||
function properties(base, iter_, prop = "description") iter(function _properties() {
|
||||
function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&");
|
||||
|
||||
prop = prop || "description";
|
||||
for (var obj in iter_) {
|
||||
if (!obj.hive || obj.hive.name !== "user") {
|
||||
yield key(prop) + " = " + obj[prop];
|
||||
|
||||
@@ -382,8 +382,7 @@ var Styles = Module("Styles", {
|
||||
return val;
|
||||
},
|
||||
|
||||
completeSite: function (context, content, group) {
|
||||
group = group || styles.user;
|
||||
completeSite: function (context, content, group = styles.user) {
|
||||
context.anchored = false;
|
||||
try {
|
||||
context.fork("current", 0, this, function (context) {
|
||||
|
||||
@@ -467,9 +467,7 @@ var Template = Module("Template", {
|
||||
["td", { style: style[i] || "" }, d])])];
|
||||
},
|
||||
|
||||
usage: function usage(iter, format) {
|
||||
|
||||
format = format || {};
|
||||
usage: function usage(iter, format = {}) {
|
||||
let desc = format.description || (item => this.linkifyHelp(item.description));
|
||||
let help = format.help || (item => item.name);
|
||||
let sourceLink = (frame) => {
|
||||
|
||||
Reference in New Issue
Block a user