<commit_before>var registry = directiveRegistry;

function compile(node) {
  var nodes;

  if(isArray(node) || (node instanceof NodeList === true)) {
    nodes = node;
    node = null;
  } else {
    nodes = [];
    nodes.push(node);
  }

  var compositeLinkFn = compileNodes(nodes);

  return function(scope) {
    if(compositeLinkFn) {
      compositeLinkFn(scope);
    }
  };
}

/**
 * Apply a set of directives to a node element:
 *  - Execute the compile function of all the directives instances
 *  - Store the retrieved linking functions from the execution of the compile function
 *
 * Returns the node link function
 */
function apply(directives, node, attributes) {
  var i,
      ii,
      linkFn,
      directive;

  // pre/post links
  var preLinkFns = [],
      postLinkFns = [];

  for(i = 0, ii = directives.length; i < ii; i++) {
    directive = directives[i];

    linkFn = directive.compile(node, attributes);

    if(isFunction(linkFn)) {
      addLinkFn(0, linkFn);
    } else if(isObject(linkFn)) {
      addLinkFn(linkFn.pre, linkFn.post);
    }
  }

  function addLinkFn (pre, post, directive) {
    if(pre) {
      preLinkFns.push(pre);
    }

    if(post) {
      postLinkFns.push(post);
    }
  }

  /**
   *  - Executes the pre and post linking functions
   */
  return function nodeLinkFn (scope, childLinkFn) {
    var i;

    for(i = 0; i < preLinkFns.length; i++) {
      invokeLinkFn(preLinkFns[i],
        scope,
        node,
        attributes
      );
    }

    if(childLinkFn) {
      childLinkFn(scope, node.childNodes);
    }

    for(i = postLinkFns.length - 1; i >= 0; i--) {
      invokeLinkFn(postLinkFns[i],
        scope,
        node,
        attributes
      );
    }
  };
}

function invokeLinkFn(linkFn, scope, node, attributes) {
  linkFn(scope, node, attributes);
}

function addDirective(name, directives) {
  var i,
      ii,
      instances;

  if((instances = registry.$$get(name))) {
    for(i = 0, ii = instances.length; i < ii; i++) {
      directives.push(instances[i]);
    }
  }
}

function scan(node, directives, attributes) {
  var i,
      ii,
      name = camelCase(node.tagName),
      attr,<commit_msg>chore(src/compile.js): store the post/pre links in a variable before invoke them, since in future we will need to get some properties we stored previously in each link function (i.e. "require", "directiveName" etc)<commit_after>var registry = directiveRegistry;

function compile(node) {
  var nodes;

  if(isArray(node) || (node instanceof NodeList === true)) {
    nodes = node;
    node = null;
  } else {
    nodes = [];
    nodes.push(node);
  }

  var compositeLinkFn = compileNodes(nodes);

  return function(scope) {
    if(compositeLinkFn) {
      compositeLinkFn(scope);
    }
  };
}

/**
 * Apply a set of directives to a node element:
 *  - Execute the compile function of all the directives instances
 *  - Store the retrieved linking functions from the execution of the compile function
 *
 * Returns the node link function
 */
function apply(directives, node, attributes) {
  var i,
      ii,
      linkFn,
      directive;

  // pre/post links
  var preLinkFns = [],
      postLinkFns = [];

  for(i = 0, ii = directives.length; i < ii; i++) {
    directive = directives[i];

    linkFn = directive.compile(node, attributes);

    if(isFunction(linkFn)) {
      addLinkFn(0, linkFn);
    } else if(isObject(linkFn)) {
      addLinkFn(linkFn.pre, linkFn.post);
    }
  }

  function addLinkFn (pre, post, directive) {
    if(pre) {
      preLinkFns.push(pre);
    }

    if(post) {
      postLinkFns.push(post);
    }
  }

  /**
   *  - Executes the pre and post linking functions
   */
  return function nodeLinkFn (scope, childLinkFn) {
    var i;

    for(i = 0; i < preLinkFns.length; i++) {
      linkFn = preLinkFns[i];
      invokeLinkFn(linkFn,
        scope,
        node,
        attributes
      );
    }

    if(childLinkFn) {
      childLinkFn(scope, node.childNodes);
    }

    for(i = postLinkFns.length - 1; i >= 0; i--) {
      linkFn = postLinkFns[i];
      invokeLinkFn(linkFn,
        scope,
        node,
        attributes
      );
    }
  };
}

function invokeLinkFn(linkFn, scope, node, attributes) {
  linkFn(scope, node, attributes);
}

function addDirective(name, directives) {
  var i,
      ii,
      instances;

  if((instances = registry.$$get(name))) {
    for(i = 0, ii = instances.length; i < ii; i++) {
      directives.push(instances[i]);
    }
  }
}

function scan(node, directives, attributes) {
  var i,
      ii,
      name = camelCase(node.tagName),
      attr,
{'fraction_non_alphanumeric': 0.12682501634342994, 'fraction_numerical': 0.0026149487905861844, 'mean_word_length': 2.51185921958684, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1301767', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1500, 'n_words': 382}