<commit_before>/**
 * Returns an array of nodes in the passed AST, traversed using BFS. Accepts an
 * optional maximum number, n, of nodes to return. The returned array always
 * begins with the root node.
 *
 * @param {Node} node The root node of the AST to traverse
 * @param {int}  [n]  Optional max number of nodes to return
 */
module.exports = function(node, n) {
  var queue, res, i, children;

  queue = [node];
  res = [node];

  while (queue.length > 0) {
    node = queue.shift();

    if (n && res.length >= n) {
      return res.slice(0, n);
    }

    children = getChildren(node) || [];
    for (i = 0; i < children.length; i++) {
      queue.push(children[i]);
      res.push(children[i]);
    }
  }

  return res.slice(0, n);
};

/**
 * Returns a given node's children as an array of nodes. Designed for use
 * with acorn's ASTs.
 *
 * @param   {Node}   The node for which to retrieve its children
 * @returns {Node[]} An array of child nodes
 */
function getChildren(node) {
  var res, temp, i, j;

  switch (node.type) {
    case 'Expression':
    case 'ThisExpression':
    case 'Statement':
    case 'BreakStatement':
    case 'ContinueStatement':
    case 'EmptyStatement':
    case 'DebuggerStatement':
    case 'ForInit':
    case 'ScopeBody':
    case 'Identifier':
    case 'Literal':
    case 'ExportDeclaration':
    case 'ImportDeclaration':
      return [];

    case 'Program':
    case 'BlockStatement':
      res = [];
      for (i = 0; i < node.body.length; i++) {
        if (node.body[i]) res.push(node.body[i]);<commit_msg>Handle super and meta properties https://github.com/ternjs/acorn/commit/659f2c909124b7e4cf5f460a85a644e08c906897<commit_after>/**
 * Returns an array of nodes in the passed AST, traversed using BFS. Accepts an
 * optional maximum number, n, of nodes to return. The returned array always
 * begins with the root node.
 *
 * @param {Node} node The root node of the AST to traverse
 * @param {int}  [n]  Optional max number of nodes to return
 */
module.exports = function(node, n) {
  var queue, res, i, children;

  queue = [node];
  res = [node];

  while (queue.length > 0) {
    node = queue.shift();

    if (n && res.length >= n) {
      return res.slice(0, n);
    }

    children = getChildren(node) || [];
    for (i = 0; i < children.length; i++) {
      queue.push(children[i]);
      res.push(children[i]);
    }
  }

  return res.slice(0, n);
};

/**
 * Returns a given node's children as an array of nodes. Designed for use
 * with acorn's ASTs.
 *
 * @param   {Node}   The node for which to retrieve its children
 * @returns {Node[]} An array of child nodes
 */
function getChildren(node) {
  var res, temp, i, j;

  switch (node.type) {
    case 'Expression':
    case 'ThisExpression':
    case 'Super':
    case 'MetaProperty':
    case 'Statement':
    case 'BreakStatement':
    case 'ContinueStatement':
    case 'EmptyStatement':
    case 'DebuggerStatement':
    case 'ForInit':
    case 'ScopeBody':
    case 'Identifier':
    case 'Literal':
    case 'ExportDeclaration':
    case 'ImportDeclaration':
      return [];

    case 'Program':
    case 'BlockStatement':
      res = [];
      for (i = 0; i < node.body.length; i++) {
        if (node.body[i]) res.push(node.body[i]);
{'fraction_non_alphanumeric': 0.13733905579399142, 'fraction_numerical': 0.011955855303494788, 'mean_word_length': 2.870699881376038, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, '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': '1928064', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1025, 'n_words': 354}