a shy attempt to obey width in the beautifier; added bracketize option to always print brackets around if/do/while/for statements; export more options via the CLI

This commit is contained in:
Mihai Bazon
2012-10-02 11:00:47 +03:00
parent 896444482a
commit 9e5dd81f1e
5 changed files with 117 additions and 49 deletions

View File

@@ -96,10 +96,17 @@ function repeat_string(str, i) {
return d;
};
function defaults(args, defs) {
function DefaultsError(msg, defs) {
this.msg = msg;
this.defs = defs;
};
function defaults(args, defs, croak) {
if (args === true)
args = {};
var ret = args || {};
if (croak) for (var i in ret) if (HOP(ret, i) && !HOP(defs, i))
throw new DefaultsError("`" + i + "` is not a supported option", defs);
for (var i in defs) if (HOP(defs, i)) {
ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
}