<commit_before>'use strict';


// non-destructive changes to EcmaScript code using an "enhanced" AST for the
// process, it updates the tokens in place and add/remove spaces & line breaks
// based on user settings.
// not using any kind of code rewrite based on string concatenation to avoid
// breaking the program correctness and/or undesired side-effects.


var _br = require('./lineBreak');
var _options = require('./options');
var _tk = require('rocambole-token');
var _ws = require('./whiteSpace');
var addBrAroundNode = require('./lineBreakAroundNode');
var expressionParentheses = require('./hooks/expressionParentheses');
var hooks = require('./hooks');
var indent = require('./indent');
var plugins = require('./plugins');
var rocambole = require('rocambole');


// ---


var _shouldRemoveTrailingWs;


// ---


exports.hooks = hooks;
exports.format = format;
exports.transform = transform;
exports.rc = _options.getRc;
exports.register = plugins.register;
exports.unregister = plugins.unregister;
exports.unregisterAll = plugins.unregisterAll;


// ---


function format(str, opts) {
  // we need to load and register the plugins as soon as possible otherwise
  // `stringBefore` won't be called.
  plugins.loadAndRegister(opts && opts.plugins);
  str = plugins.stringBefore(str);
  var ast = rocambole.parse(str);
  transform(ast, opts);<commit_msg>make sure we don't loop over same CatchClause twice. fixes #264<commit_after>'use strict';


// non-destructive changes to EcmaScript code using an "enhanced" AST for the
// process, it updates the tokens in place and add/remove spaces & line breaks
// based on user settings.
// not using any kind of code rewrite based on string concatenation to avoid
// breaking the program correctness and/or undesired side-effects.


var _br = require('./lineBreak');
var _options = require('./options');
var _tk = require('rocambole-token');
var _ws = require('./whiteSpace');
var addBrAroundNode = require('./lineBreakAroundNode');
var expressionParentheses = require('./hooks/expressionParentheses');
var hooks = require('./hooks');
var indent = require('./indent');
var plugins = require('./plugins');
var rocambole = require('rocambole');

// esprima@2.1 introduces a "handler" property on TryStatement, so we would
// loop the same node twice (see jquery/esprima/issues/1031 and #264)
rocambole.BYPASS_RECURSION.handler = true;

// ---


var _shouldRemoveTrailingWs;


// ---


exports.hooks = hooks;
exports.format = format;
exports.transform = transform;
exports.rc = _options.getRc;
exports.register = plugins.register;
exports.unregister = plugins.unregister;
exports.unregisterAll = plugins.unregisterAll;


// ---


function format(str, opts) {
  // we need to load and register the plugins as soon as possible otherwise
  // `stringBefore` won't be called.
  plugins.loadAndRegister(opts && opts.plugins);
  str = plugins.stringBefore(str);
  var ast = rocambole.parse(str);
  transform(ast, opts);
{'fraction_non_alphanumeric': 0.1276595744680851, 'fraction_numerical': 0.004052684903748734, 'mean_word_length': 4.327338129496403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4779582', 'n_tokens_mistral': 863, 'n_tokens_neox': 825, 'n_words': 278}