lib/zest.js
function(sel) {
  var filter = []
    , comb = combinators.noop
    , qname
    , cap
    , op
    , len;

  // add implicit universal selectors
  sel = sel.replace(/(^|\s)(:|\[|\.|#)/g, '$1*$2');

  while (cap = /\s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$/.exec(sel)) {
    len = sel.length - cap[0].length;
    cap = cap[1].split(/(?=[\[:.#])/);
    if (!qname) qname = cap[0];
    filter.push(comb(parse(cap)));
    if (len) {
      op = sel[len - 1];
      // if the combinator doesn't exist, 
      // assume it was a whitespace.
      comb = combinators[op] || combinators[op = ' '];
      sel = sel.substring(0, op !== ' ' ? --len : len);
    } else {
      break;
    }
  }

  // compile to a single function
  filter = make(filter);

  // optimize the first qname
  filter.qname = qname;

  return filter;
}
function(sel) {
  var filter = []
    , comb = combinators.noop
    , qname
    , cap
    , op
    , len;

  // add implicit universal selectors
  sel = sel.replace(/(^|\s)(:|\[|\.|#)/g, '$1*$2');

  while (cap = /\s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$/.exec(sel)) {
    len = sel.length - cap[0].length;
    cap = cap[1].split(/(?=[\[:.#])/);
    if (!qname) qname = cap[0];
    filter.push(comb(parse(cap)));
    if (len) {
      op = sel[len - 1];
      // if the combinator doesn't exist, 
      // assume it was a whitespace.
      comb = combinators[op] || combinators[op = ' '];
      sel = sel.substring(0, op !== ' ' ? --len : len);
    } else {
      break;
    }
  }

  // compile to a single function
  filter = make(filter);

  // optimize the first qname
  filter.qname = qname;

  return filter;
}
function ( sel ) { var filter = [ ] , comb = combinators . noop , qname , cap , op , len ; // add implicit universal selectors sel = sel . replace ( / (^|\s)(:|\[|\.|#) / g , '$1*$2' ) ; while ( cap = / \s*((?:\w+|\*)(?:[.#:][^\s]+|\[[^\]]+\])*)\s*$ / . exec ( sel ) ) { len = sel . length - cap [ 0 ] . length ; cap = cap [ 1 ] . split ( / (?=[\[:.#]) / ) ; if ( ! qname ) qname = cap [ 0 ] ; filter . push ( comb ( parse ( cap ) ) ) ; if ( len ) { op = sel [ len - 1 ] ; // if the combinator doesn't exist,  // assume it was a whitespace. comb = combinators [ op ] || combinators [ op = ' ' ] ; sel = sel . substring ( 0 , op !== ' ' ? -- len : len ) ; } else { break ; } } // compile to a single function filter = make ( filter ) ; // optimize the first qname filter . qname = qname ; return filter ; }
parse and compile the selector into a single filter function
parse and compile the selector into a single filter function