Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / node_modules / protobufjs / cli / pbjs / targets / js.js
diff --git a/legacy-libs/grpc-cloned/node_modules/protobufjs/cli/pbjs/targets/js.js b/legacy-libs/grpc-cloned/node_modules/protobufjs/cli/pbjs/targets/js.js
new file mode 100644 (file)
index 0000000..4f9ee12
--- /dev/null
@@ -0,0 +1,63 @@
+/*\r
+ Copyright 2013 Daniel Wirtz <dcode@dcode.io>\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+ */\r
+var description = "Runtime structures";\r
+\r
+var util = require("../util.js"),\r
+    json = require("./json.js");\r
+\r
+/**\r
+ * pbjs target: Runtime structures\r
+ * @exports pbjs/targets/js\r
+ * @function\r
+ * @param {!ProtoBuf.Builder} builder Builder\r
+ * @param {!Object.<string,*>=} options Options\r
+ * @returns {string}\r
+ */\r
+var js = module.exports = function(builder, options) {\r
+    options = options || {};\r
+    var varName = "_root";\r
+    if (options.exports)\r
+        varName = options.exports.substring(options.exports.lastIndexOf(".")+1);\r
+    return [\r
+        "var ", varName, options.min ? "=" : " = ", options.dependency || "dcodeIO.ProtoBuf",\r
+        js.build(builder, options)\r
+    ].join('');\r
+};\r
+\r
+/**\r
+ * Builds the core js target.\r
+ * @param {!ProtoBuf.Builder} builder Builder\r
+ * @param {!Object.<string,*>=} options Options\r
+ * @returns {string}\r
+ */\r
+js.build = function(builder, options) {\r
+    options = options || {};\r
+    return [\r
+        ".newBuilder(",\r
+        JSON.stringify(util.getBuilderOptions(options, "use"), null, options.min ? 0 : 4),\r
+        ")['import'](",\r
+        json(builder, options),\r
+        ").build(",\r
+        typeof options.exports === 'string' ? JSON.stringify(options.exports.split(".")) : "",\r
+        ");"\r
+    ].join('');\r
+};\r
+\r
+/**\r
+ * Module description.\r
+ * @type {string}\r
+ */\r
+js.description = description;\r