<commit_before>let sourceCode
let writes

function printNode(node) {
  if (!writes) {
    return
  }
  _printNode(node, 2, 0)
}

function print(str) {
  if (writes) {
    console.log(str)
  }
}

function _printNode(node, lvl, indent) {
  if (lvl === 0) return
  if (node == null) return
  if (node.type != null) {
    let ind = []
    for (let i = 0; i < indent + 1; i++) {
      ind.push('  ')
    }
    ind = ind.join('')
    console.log(ind + node.type)
    if ('loc' in node) {
      let sl = node.loc.start.line
      let el = node.loc.end.line
      if (sl !== el) {throw new Error('sl != el')}
      let toPrint = []
      for (let i = 0; i < indent + 1; i++) {
        toPrint.push('  ')
      }
      console.log(ind + '  ' + sourceCode[sl - 1].substring(node.loc.start.column, node.loc.end.column))
    }
    for (let k of Object.keys(node)) {
      _printNode(node[k], lvl - 1, indent + 1)
    }
  }
}


export default function({types: t}) {

  /*
    Babel 7 renamed RestProperty to RestElement.
    Check which one is available, then make a copy of it for future references.
    Prefer the older version when both exist for babel 6 compatibility
  */
  const isRestElement = (tx, node, opts) => 
    tx.isRestElement && !tx.isRestProperty ? 
        tx.isRestElement(node, opts) :
        tx.isRestProperty(node, opts);

  function generateRequire(pkgName, methodName)  {
    return t.variableDeclaration(
      'var',
      [
        t.variableDeclarator(
          t.identifier('__extensible_get__'),
          t.memberExpression(
            t.callExpression(
              t.identifier('require'),
              [
                t.stringLiteral(pkgName)
              ]
            ),
            t.identifier(methodName),
            false
          )
        )
      ]
    )
  };

  function extensibleGet(obj, prop, def) {
    let args = [obj, prop]
    if (def !== undefined) {
      args.push(def)
    }<commit_msg>Add an explicit test of the current Babel version<commit_after>let sourceCode
let writes

function printNode(node) {
  if (!writes) {
    return
  }
  _printNode(node, 2, 0)
}

function print(str) {
  if (writes) {
    console.log(str)
  }
}

function _printNode(node, lvl, indent) {
  if (lvl === 0) return
  if (node == null) return
  if (node.type != null) {
    let ind = []
    for (let i = 0; i < indent + 1; i++) {
      ind.push('  ')
    }
    ind = ind.join('')
    console.log(ind + node.type)
    if ('loc' in node) {
      let sl = node.loc.start.line
      let el = node.loc.end.line
      if (sl !== el) {throw new Error('sl != el')}
      let toPrint = []
      for (let i = 0; i < indent + 1; i++) {
        toPrint.push('  ')
      }
      console.log(ind + '  ' + sourceCode[sl - 1].substring(node.loc.start.column, node.loc.end.column))
    }
    for (let k of Object.keys(node)) {
      _printNode(node[k], lvl - 1, indent + 1)
    }
  }
}


export default function({types: t, version}) {
  const majorVersion = Number(version.split('.')[0]);

  /*
    Babel 7 renamed RestProperty to RestElement.
    Check the Babel version number supplied to the plugin
    and return the result of the preferred function call.
  */
  const isRestElement = (tx, node, opts) =>
    majorVersion >= 7
      ? tx.isRestElement(node, opts)
      : tx.isRestProperty(node, opts);

  function generateRequire(pkgName, methodName)  {
    return t.variableDeclaration(
      'var',
      [
        t.variableDeclarator(
          t.identifier('__extensible_get__'),
          t.memberExpression(
            t.callExpression(
              t.identifier('require'),
              [
                t.stringLiteral(pkgName)
              ]
            ),
            t.identifier(methodName),
            false
          )
        )
      ]
    )
  };

  function extensibleGet(obj, prop, def) {
    let args = [obj, prop]
    if (def !== undefined) {
      args.push(def)
    }
{'fraction_non_alphanumeric': 0.1351903910043445, 'fraction_numerical': 0.006388959877331971, 'mean_word_length': 2.0038372985418267, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '5271568', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1273, 'n_words': 327}