lib/index.js
/**
     * Returns an iterator set on the position of the first occurrence
     * of a given string in the current string, or null otherwise
     * @param {Utf8String} otherString
     * @param {CodePointsIterator=} mainIterator
     * @returns {CodePointsIterator|null}
     */
Returns an iterator set on the position of the first occurrence
of a given string in the current string, or null otherwise
@param {Utf8String} otherString
@param {CodePointsIterator=} mainIterator
@returns {CodePointsIterator|null}
Returns an iterator set on the position of the first occurrence of a given string in the current string or null otherwise @param { Utf8String } otherString @param { CodePointsIterator = } mainIterator @returns { CodePointsIterator|null }
find(otherString, mainIterator) {
        if (mainIterator === undefined || mainIterator === null) {
            mainIterator = this.codePoints();
        } else if (!(mainIterator instanceof CodePointsIterator)) {
            error('start iterator must be a valid iterator');
        } else {
            mainIterator = mainIterator.clone();
        }
        const otherIterator = otherString.codePoints();
        let otherI = otherIterator.i;
        let mainI = mainIterator.i;
        let mainValue = mainIterator.current().value;
        let prevI = mainIterator.i;
        let prevValue = mainIterator.current().value;
        let mainCurrent;
        let otherCurrent;
        let mainNfdIterator = createNfdIterator(mainIterator);
        let otherNfdIterator = createNfdIterator(otherIterator);
        while (!(mainCurrent = mainNfdIterator.next()).done) {
            prevI = mainI;
            prevValue = mainValue;
            mainI = mainIterator.i;
            mainValue = mainCurrent.value;
            while (!(otherCurrent = otherNfdIterator.next()).done && !mainCurrent.done) {
                if (mainCurrent.value === otherCurrent.value) {
                    mainCurrent = mainNfdIterator.next();
                } else {
                    mainIterator.i = mainI;
                    otherIterator.i = otherI;
                    mainNfdIterator = createNfdIterator(mainIterator);
                    otherNfdIterator = createNfdIterator(otherIterator);
                    break;
                }
            }
            if (otherCurrent.done) {
                mainIterator.i = prevI;
                mainIterator.output = {
                    value: prevValue,
                    done: false
                };
                return mainIterator;
            }
        }
        return null;
    }
find ( otherString , mainIterator ) { if ( mainIterator === undefined || mainIterator === null ) { mainIterator = this . codePoints ( ) ; } else if ( ! ( mainIterator instanceof CodePointsIterator ) ) { error ( 'start iterator must be a valid iterator' ) ; } else { mainIterator = mainIterator . clone ( ) ; } const otherIterator = otherString . codePoints ( ) ; let otherI = otherIterator . i ; let mainI = mainIterator . i ; let mainValue = mainIterator . current ( ) . value ; let prevI = mainIterator . i ; let prevValue = mainIterator . current ( ) . value ; let mainCurrent ; let otherCurrent ; let mainNfdIterator = createNfdIterator ( mainIterator ) ; let otherNfdIterator = createNfdIterator ( otherIterator ) ; while ( ! ( mainCurrent = mainNfdIterator . next ( ) ) . done ) { prevI = mainI ; prevValue = mainValue ; mainI = mainIterator . i ; mainValue = mainCurrent . value ; while ( ! ( otherCurrent = otherNfdIterator . next ( ) ) . done && ! mainCurrent . done ) { if ( mainCurrent . value === otherCurrent . value ) { mainCurrent = mainNfdIterator . next ( ) ; } else { mainIterator . i = mainI ; otherIterator . i = otherI ; mainNfdIterator = createNfdIterator ( mainIterator ) ; otherNfdIterator = createNfdIterator ( otherIterator ) ; break ; } } if ( otherCurrent . done ) { mainIterator . i = prevI ; mainIterator . output = { value : prevValue , done : false } ; return mainIterator ; } } return null ; }
Returns an iterator set on the position of the first occurrence
 of a given string in the current string, or null otherwise
 @param {Utf8String} otherString
 @param {CodePointsIterator=} mainIterator
 @returns {CodePointsIterator|null}
Returns an iterator set on the position of the first occurrence of a given string in the current string or null otherwise @param { Utf8String } otherString @param { CodePointsIterator = } mainIterator @returns { CodePointsIterator|null }
// TODO Optimize, Optimize, Optimize