Skip to content

Commit dd96dcd

Browse files
committed
Other: Various other minor improvements / assertions refactored away, see #653
1 parent 735da43 commit dd96dcd

39 files changed

+390
-672
lines changed

cli/targets/static.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ function static_target(root, options, callback) {
3939
else
4040
push("// Exported root namespace");
4141
}
42-
var rootName = config.root || "default";
43-
push("var $root = $protobuf.roots[" + JSON.stringify(rootName) + "] || ($protobuf.roots[" + JSON.stringify(rootName) + "] = {});");
42+
var rootProp = cliUtil.safeProp(config.root || "default");
43+
push("var $root = $protobuf.roots" + rootProp + " || ($protobuf.roots" + rootProp + " = {});");
4444
buildNamespace(null, root);
4545
push("");
4646
if (config.comments)
@@ -274,15 +274,13 @@ function buildType(ref, type) {
274274
]);
275275
push("function " + name(type.name) + "(properties) {");
276276
++indent;
277-
push("if (properties) {");
277+
push("if (properties)");
278278
++indent;
279-
push("var keys = Object.keys(properties);");
280-
push("for (var i = 0; i < keys.length; ++i)");
279+
push("for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)");
281280
++indent;
282281
push("this[keys[i]] = properties[keys[i]];");
283282
--indent;
284283
--indent;
285-
push("}");
286284
--indent;
287285
push("}");
288286

0 commit comments

Comments
 (0)