Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

@protobufjs/codegen

Package Overview
Dependencies
0
Maintainers
2
Versions
14
Issues
File Explorer

Advanced tools

@protobufjs/codegen

A minimalistic code generation utility.

    2.0.4latest

Version published
Maintainers
2
Weekly downloads
6,432,691
decreased by-11.02%

Weekly downloads

Readme

Source

@protobufjs/codegen

npm

A minimalistic code generation utility.

API

  • codegen([functionParams: string[]], [functionName: string]): Codegen
    Begins generating a function.

  • codegen.verbose = false
    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
    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
  • Codegen([scope: Object.<string,*>]): Function
    Finishes the function and returns it.

  • Codegen.toString([functionNameOverride: string]): string
    Returns the function as a string.

Example

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

FAQs

What is @protobufjs/codegen?

A minimalistic code generation utility.

Is @protobufjs/codegen popular?

The npm package @protobufjs/codegen receives a total of 6,137,725 weekly downloads. As such, @protobufjs/codegen popularity was classified as popular.

Is @protobufjs/codegen well maintained?

We found that @protobufjs/codegen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 09 Jun 2017

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc