function isPatternNext(pattern, pos, flags, needlePattern) {
    var inlineCommentPattern = '\\(\\?#[^)]*\\)';
    var lineCommentPattern = '#[^#\\n]*';
    var patternsToIgnore = flags.indexOf('x') > -1 ?
        // Ignore any leading whitespace, line comments, and inline comments
        ['\\s', lineCommentPattern, inlineCommentPattern] :
        // Ignore any leading inline comments
        [inlineCommentPattern];
    return nativ.test.call(
        new RegExp('^(?:' + patternsToIgnore.join('|') + ')*(?:' + needlePattern + ')'),
        pattern.slice(pos)
    );
}
Checks whether the next nonignorable token after the specified position matches the
`needlePattern`

@private
@param {String} pattern Pattern to search within.
@param {Number} pos Index in `pattern` to search at.
@param {String} flags Flags used by the pattern.
@param {String} needlePattern Pattern to match the next token against.
@returns {Boolean} Whether the next nonignorable token matches `needlePattern`