index.js
function format(opt_clangOptions, opt_clangFormat) {
  var actualClangFormat = opt_clangFormat || clangFormat;
  var optsStr = getOptsString(opt_clangOptions);

  function formatFilter(file, enc, done) {
    function onClangFormatFinished() {
      file.contents = Buffer.from(formatted, 'utf-8');
      done(null, file);
    }
    var formatted = '';
    actualClangFormat(file, enc, optsStr, onClangFormatFinished)
        .on('data', function(b) { formatted += b.toString(); })
        .on('error', this.emit.bind(this, 'error'));
  }
  return through2.obj(formatFilter);
}
function format(opt_clangOptions, opt_clangFormat) {
  var actualClangFormat = opt_clangFormat || clangFormat;
  var optsStr = getOptsString(opt_clangOptions);

  function formatFilter(file, enc, done) {
    function onClangFormatFinished() {
      file.contents = Buffer.from(formatted, 'utf-8');
      done(null, file);
    }
    var formatted = '';
    actualClangFormat(file, enc, optsStr, onClangFormatFinished)
        .on('data', function(b) { formatted += b.toString(); })
        .on('error', this.emit.bind(this, 'error'));
  }
  return through2.obj(formatFilter);
}
function format ( opt_clangOptions , opt_clangFormat ) { var actualClangFormat = opt_clangFormat || clangFormat ; var optsStr = getOptsString ( opt_clangOptions ) ; function formatFilter ( file , enc , done ) { function onClangFormatFinished ( ) { file . contents = Buffer . from ( formatted , 'utf-8' ) ; done ( null , file ) ; } var formatted = '' ; actualClangFormat ( file , enc , optsStr , onClangFormatFinished ) . on ( 'data' , function ( b ) { formatted += b . toString ( ) ; } ) . on ( 'error' , this . emit . bind ( this , 'error' ) ) ; } return through2 . obj ( formatFilter ) ; }
Formats files using clang-format.

@param {(string|Object)=} opt_clangOptions the string 'file' to search for a
'.clang-format' file, or an object literal containing clang-format options
http://clang.llvm.org/docs/ClangFormatStyleOptions.html#configurable-format-style-options
@param {Object=} opt_clangFormat A clang-format module to optionally use.
Formats files using clang - format .