@protobufjs/codegen
Advanced tools
+16
-2
@@ -8,2 +8,3 @@ export = codegen; | ||
| * @returns Itself or the generated function if finished | ||
| * @throws {Error} If format parameter counts do not match | ||
| */ | ||
@@ -14,6 +15,19 @@ type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function); | ||
| * Begins generating a function. | ||
| * @param [functionParams] Function parameter names | ||
| * @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; | ||
| 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; | ||
| namespace codegen { | ||
| /** When set to `true`, codegen will log generated code to console. Useful for debugging. */ | ||
| let verbose: boolean; | ||
| } |
+19
-5
| "use strict"; | ||
| module.exports = codegen; | ||
| codegen.verbose = false; | ||
| /** | ||
| * Begins generating a function. | ||
| * @memberof util | ||
| * @param {string[]} [functionParams] Function parameter names | ||
| * @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 | ||
| * @property {boolean} verbose=false When set to `true`, codegen will log generated code to console. Useful for debugging. | ||
| */ | ||
@@ -46,3 +43,4 @@ function codegen(functionParams, functionName) { | ||
| console.log("codegen: " + source); // eslint-disable-line no-console | ||
| return Function.apply(null, scopeParams.concat("return " + source)).apply(null, scopeValues); | ||
| scopeParams.push("return " + source); | ||
| return Function.apply(null, scopeParams).apply(null, scopeValues); | ||
| } | ||
@@ -70,1 +68,17 @@ var formatParams = Array.prototype.slice.call(arguments, 1), | ||
| } | ||
| /** | ||
| * 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; |
+1
-1
| { | ||
| "name": "@protobufjs/codegen", | ||
| "description": "Minimalistic code generation utility.", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>", | ||
@@ -6,0 +6,0 @@ "repository": { |
8107
9.85%106
29.27%