index.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. export = codegen;
  2. /**
  3. * Appends code to the function's body.
  4. * @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
  5. * @param [formatParams] Format parameters
  6. * @returns Itself or the generated function if finished
  7. * @throws {Error} If format parameter counts do not match
  8. */
  9. type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
  10. /**
  11. * Begins generating a function.
  12. * @param functionParams Function parameter names
  13. * @param [functionName] Function name if not anonymous
  14. * @returns Appender that appends code to the function's body
  15. */
  16. declare function codegen(functionParams: string[], functionName?: string): Codegen;
  17. /**
  18. * Begins generating a function.
  19. * @param [functionName] Function name if not anonymous
  20. * @returns Appender that appends code to the function's body
  21. */
  22. declare function codegen(functionName?: string): Codegen;
  23. declare namespace codegen {
  24. /** When set to `true`, codegen will log generated code to console. Useful for debugging. */
  25. let verbose: boolean;
  26. }