code: function(param, test) {
    var $ = param.replace(/\s+/g, '')
      , group
      , offset;
  
    if ($ === 'even') $ = '2n+0';
    else if ($ === 'odd') $ = '2n+1';
    else if (!~$.indexOf('n')) $ = '0n' + $;
  
    $ = /^([+-])?(\d+)?n([+-])?(\d+)?$/.exec($);
    group = $[1] === '-' ? -($[2] || 1) : +($[2] || 1);
    offset = $[4] ? ($[3] === '-' ? -$[4] : +$[4]) : 0;
    param = $ = null;
  
    return function(el) {
      if (el.parentNode.nodeType !== 1) return;
  
      var diff
        , pos = 0
        , rel = child(el.parentNode);
  
      while (rel) {
        if (test(rel, el)) pos++;
        if (rel === el) {
          diff = pos - offset;
          return !group ? !diff : !(diff % group);
        }
        rel = next(rel);
      }
    };
  }
docs: Handle `nth` Selectors