code: function doLookahead(pidx, ch, pattern, testFn) {
  	for (let lidx=pidx, sym; sym=pattern[lidx]; lidx++) {
  		const listeralEscape = sym == '/';
  		const operatorIdx = listeralEscape ?lidx+2 :lidx+1;
  		const optional = pattern[operatorIdx] == '?';
  		const oneOrMore = pattern[operatorIdx] == '+';
  
  		if (listeralEscape && lidx+1 == pattern.length) {
  			throw new Error("/ literal escape character cannot terminate a pattern");
  		}
  
  		switch (sym) {
  			case '.':  // number required
  				if (anyCharTestFn(ch)) {
  					return lidx;
  				}
  
  				break;
  			case '(':  // capture group
  				// not exactly clear how capture groups should be handled so doing something simple for
  				// now and just stopping when hit one.
  				return lidx
  			case 'd':  // number required
  				if (digitTestFn(ch)) {
  					return lidx;
  				}
  
  				break;
  			default:   // literal
  				if (listeralEscape) {
  					sym = pattern[lidx+1];
  				}
  
  				if (sym == ch) {
  					return lidx;
  				}
  		}
  
  		if (listeralEscape) {
  			// consume the escape operator
  			lidx++;
  		}
  
  		if (oneOrMore || optional) {
  			//consume the operator: + or ?
  			lidx++;   // for loop will also ++
  		}
  	}
  }
docs: ************************************************************************************************
  helper functions
  ************************************************************************************************* /*
  Finds the next matching pattern symbol for the current value character.