index.js
function (source, fileExtension, globalOptions, beautify, callback) {
  var _this = this;

  if (globalOptions === null) {
    rcFile.for(this.resourcePath, function (err, path) {
      if (!err) {
        if (typeof path === "string") {
          _this.addDependency(path);

          fs.readFile(path, "utf8", function (err, file) {
            if (!err) {
              var options = getOptionsForExtension(JSON.parse(stripJsonComments(file)), fileExtension);
              callback(null, beautify(source, options));
            } else {
              callback(err);
            }
          });
        } else {
          callback(null, beautify(source, {}));
        }
      } else {
        callback(err);
      }
    });
  } else {
    callback(null, beautify(source, getOptionsForExtension(globalOptions, fileExtension)));
  }
}
function (source, fileExtension, globalOptions, beautify, callback) {
  var _this = this;

  if (globalOptions === null) {
    rcFile.for(this.resourcePath, function (err, path) {
      if (!err) {
        if (typeof path === "string") {
          _this.addDependency(path);

          fs.readFile(path, "utf8", function (err, file) {
            if (!err) {
              var options = getOptionsForExtension(JSON.parse(stripJsonComments(file)), fileExtension);
              callback(null, beautify(source, options));
            } else {
              callback(err);
            }
          });
        } else {
          callback(null, beautify(source, {}));
        }
      } else {
        callback(err);
      }
    });
  } else {
    callback(null, beautify(source, getOptionsForExtension(globalOptions, fileExtension)));
  }
}
function ( source , fileExtension , globalOptions , beautify , callback ) { var _this = this ; if ( globalOptions === null ) { rcFile . for ( this . resourcePath , function ( err , path ) { if ( ! err ) { if ( typeof path === "string" ) { _this . addDependency ( path ) ; fs . readFile ( path , "utf8" , function ( err , file ) { if ( ! err ) { var options = getOptionsForExtension ( JSON . parse ( stripJsonComments ( file ) ) , fileExtension ) ; callback ( null , beautify ( source , options ) ) ; } else { callback ( err ) ; } } ) ; } else { callback ( null , beautify ( source , { } ) ) ; } } else { callback ( err ) ; } } ) ; } else { callback ( null , beautify ( source , getOptionsForExtension ( globalOptions , fileExtension ) ) ) ; } }
Method parses file asynchronously
@param {String} source        - file's content.
@param {String} fileExtension - file's extension.
@param {Object} globalOptions - configuration from weback file.
@param {Function} callback    - callback function with processed file content or with error message.
Method parses file asynchronously