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;
        }
/**
         * 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
         */
Appends code to the function's body or finishes generation.
Appends code to the function ' s body or finishes generation .
function Codegen(formatStringOrScope) {
          if (typeof formatStringOrScope !== "string") {
            var source = toString();
            if (codegen.verbose) console.log("codegen: " + source); 
            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); 
            }
            return Function(source)(); 
          }
          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 Codegen ( formatStringOrScope ) { if ( typeof formatStringOrScope !== "string" ) { var source = toString ( ) ; if ( codegen . verbose ) console . log ( "codegen: " + source ) ; 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 ) ; } return Function ( source ) ( ) ; } 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 ; }
Appends code to the function's body or finishes generation.
Appends code to the function ' s body or finishes generation .
// note that explicit array handling below makes this ~50% faster // finish the function // eslint-disable-line no-console // eslint-disable-line no-new-func // eslint-disable-line no-new-func // otherwise append to body