diff options
Diffstat (limited to 'frontend-old/node_modules/@protobufjs/codegen')
6 files changed, 231 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@protobufjs/codegen/LICENSE b/frontend-old/node_modules/@protobufjs/codegen/LICENSE new file mode 100644 index 0000000..2a2d560 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/frontend-old/node_modules/@protobufjs/codegen/README.md b/frontend-old/node_modules/@protobufjs/codegen/README.md new file mode 100644 index 0000000..0169338 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/README.md @@ -0,0 +1,49 @@ +@protobufjs/codegen
+===================
+[](https://www.npmjs.com/package/@protobufjs/codegen)
+
+A minimalistic code generation utility.
+
+API
+---
+
+* **codegen([functionParams: `string[]`], [functionName: string]): `Codegen`**<br />
+ Begins generating a function.
+
+* **codegen.verbose = `false`**<br />
+ When set to true, codegen will log generated code to console. Useful for debugging.
+
+Invoking **codegen** returns an appender function that appends code to the function's body and returns itself:
+
+* **Codegen(formatString: `string`, [...formatParams: `any`]): Codegen**<br />
+ Appends code to the function's body. The format string can contain placeholders specifying the types of inserted format parameters:
+
+ * `%d`: Number (integer or floating point value)
+ * `%f`: Floating point value
+ * `%i`: Integer value
+ * `%j`: JSON.stringify'ed value
+ * `%s`: String value
+ * `%%`: Percent sign<br />
+
+* **Codegen([scope: `Object.<string,*>`]): `Function`**<br />
+ Finishes the function and returns it.
+
+* **Codegen.toString([functionNameOverride: `string`]): `string`**<br />
+ Returns the function as a string.
+
+Example
+-------
+
+```js
+var codegen = require("@protobufjs/codegen");
+
+var add = codegen(["a", "b"], "add") // A function with parameters "a" and "b" named "add"
+ ("// awesome comment") // adds the line to the function's body
+ ("return a + b - c + %d", 1) // replaces %d with 1 and adds the line to the body
+ ({ c: 1 }); // adds "c" with a value of 1 to the function's scope
+
+console.log(add.toString()); // function add(a, b) { return a + b - c + 1 }
+console.log(add(1, 2)); // calculates 1 + 2 - 1 + 1 = 3
+```
+
+**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
diff --git a/frontend-old/node_modules/@protobufjs/codegen/index.d.ts b/frontend-old/node_modules/@protobufjs/codegen/index.d.ts new file mode 100644 index 0000000..f7fb921 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/index.d.ts @@ -0,0 +1,31 @@ +export = codegen;
+
+/**
+ * Appends code to the function's body.
+ * @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
+ * @param [formatParams] Format parameters
+ * @returns Itself or the generated function if finished
+ * @throws {Error} If format parameter counts do not match
+ */
+type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
+
+/**
+ * Begins generating a function.
+ * @param functionParams Function parameter names
+ * @param [functionName] Function name if not anonymous
+ * @returns Appender that appends code to the function's body
+ */
+declare function codegen(functionParams: string[], functionName?: string): Codegen;
+
+/**
+ * Begins generating a function.
+ * @param [functionName] Function name if not anonymous
+ * @returns Appender that appends code to the function's body
+ */
+declare function codegen(functionName?: string): Codegen;
+
+declare namespace codegen {
+
+ /** When set to `true`, codegen will log generated code to console. Useful for debugging. */
+ let verbose: boolean;
+}
diff --git a/frontend-old/node_modules/@protobufjs/codegen/index.js b/frontend-old/node_modules/@protobufjs/codegen/index.js new file mode 100644 index 0000000..de73f80 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/index.js @@ -0,0 +1,99 @@ +"use strict";
+module.exports = codegen;
+
+/**
+ * Begins generating a function.
+ * @memberof util
+ * @param {string[]} functionParams Function parameter names
+ * @param {string} [functionName] Function name if not anonymous
+ * @returns {Codegen} Appender that appends code to the function's body
+ */
+function codegen(functionParams, functionName) {
+
+ /* istanbul ignore if */
+ if (typeof functionParams === "string") {
+ functionName = functionParams;
+ functionParams = undefined;
+ }
+
+ var body = [];
+
+ /**
+ * Appends code to the function's body or finishes generation.
+ * @typedef Codegen
+ * @type {function}
+ * @param {string|Object.<string,*>} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
+ * @param {...*} [formatParams] Format parameters
+ * @returns {Codegen|Function} Itself or the generated function if finished
+ * @throws {Error} If format parameter counts do not match
+ */
+
+ function Codegen(formatStringOrScope) {
+ // note that explicit array handling below makes this ~50% faster
+
+ // finish the function
+ if (typeof formatStringOrScope !== "string") {
+ var source = toString();
+ if (codegen.verbose)
+ console.log("codegen: " + source); // eslint-disable-line no-console
+ source = "return " + source;
+ if (formatStringOrScope) {
+ var scopeKeys = Object.keys(formatStringOrScope),
+ scopeParams = new Array(scopeKeys.length + 1),
+ scopeValues = new Array(scopeKeys.length),
+ scopeOffset = 0;
+ while (scopeOffset < scopeKeys.length) {
+ scopeParams[scopeOffset] = scopeKeys[scopeOffset];
+ scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];
+ }
+ scopeParams[scopeOffset] = source;
+ return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func
+ }
+ return Function(source)(); // eslint-disable-line no-new-func
+ }
+
+ // otherwise append to body
+ var formatParams = new Array(arguments.length - 1),
+ formatOffset = 0;
+ while (formatOffset < formatParams.length)
+ formatParams[formatOffset] = arguments[++formatOffset];
+ formatOffset = 0;
+ formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {
+ var value = formatParams[formatOffset++];
+ switch ($1) {
+ case "d": case "f": return String(Number(value));
+ case "i": return String(Math.floor(value));
+ case "j": return JSON.stringify(value);
+ case "s": return String(value);
+ }
+ return "%";
+ });
+ if (formatOffset !== formatParams.length)
+ throw Error("parameter count mismatch");
+ body.push(formatStringOrScope);
+ return Codegen;
+ }
+
+ function toString(functionNameOverride) {
+ return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
+ }
+
+ Codegen.toString = toString;
+ return Codegen;
+}
+
+/**
+ * Begins generating a function.
+ * @memberof util
+ * @function codegen
+ * @param {string} [functionName] Function name if not anonymous
+ * @returns {Codegen} Appender that appends code to the function's body
+ * @variation 2
+ */
+
+/**
+ * When set to `true`, codegen will log generated code to console. Useful for debugging.
+ * @name util.codegen.verbose
+ * @type {boolean}
+ */
+codegen.verbose = false;
diff --git a/frontend-old/node_modules/@protobufjs/codegen/package.json b/frontend-old/node_modules/@protobufjs/codegen/package.json new file mode 100644 index 0000000..92f2c4c --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/package.json @@ -0,0 +1,13 @@ +{
+ "name": "@protobufjs/codegen",
+ "description": "A minimalistic code generation utility.",
+ "version": "2.0.4",
+ "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dcodeIO/protobuf.js.git"
+ },
+ "license": "BSD-3-Clause",
+ "main": "index.js",
+ "types": "index.d.ts"
+}
\ No newline at end of file diff --git a/frontend-old/node_modules/@protobufjs/codegen/tests/index.js b/frontend-old/node_modules/@protobufjs/codegen/tests/index.js new file mode 100644 index 0000000..f3a3db1 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/codegen/tests/index.js @@ -0,0 +1,13 @@ +var codegen = require("..");
+
+// new require("benchmark").Suite().add("add", function() {
+
+var add = codegen(["a", "b"], "add")
+ ("// awesome comment")
+ ("return a + b - c + %d", 1)
+ ({ c: 1 });
+
+if (add(1, 2) !== 3)
+ throw Error("failed");
+
+// }).on("cycle", function(event) { process.stdout.write(String(event.target) + "\n"); }).run();
|
