lib/index.js
/**
     * Returns a substring from start iterator to the
     * end of the string or to another given iterator.
     * Will throw RangeError for any invalid argument
     * including when end is
     * @param {CodePointsIterator=} startIterator
     * @param {CodePointsIterator=} endIterator
     * @throws RangeError
     */
Returns a substring from start iterator to the
end of the string or to another given iterator.
Will throw RangeError for any invalid argument
including when end is
@param {CodePointsIterator=} startIterator
@param {CodePointsIterator=} endIterator
@throws RangeError
Returns a substring from start iterator to the end of the string or to another given iterator . Will throw RangeError for any invalid argument including when end is @param { CodePointsIterator = } startIterator @param { CodePointsIterator = } endIterator @throws RangeError
substring(startIterator, endIterator) {
        const result = new Utf8String();
        if (startIterator === undefined || startIterator === null) {
            result[BYTES] = this[BYTES].slice();
        } else if (!(startIterator instanceof CodePointsIterator)) {
            error('substring() only accepts code points iterator as arguments', RangeError);
        } else if (endIterator === undefined || endIterator === null) {
            result[BYTES] = this[BYTES].slice(startIterator.i + 1);
        } else if (!(endIterator instanceof CodePointsIterator)) {
            error('substring() only accepts code points iterator as arguments', RangeError);
        } else if (endIterator.i < startIterator.i) {
            error('start of the substring must not be after the end of substring', RangeError);
        } else {
            result[BYTES] = this[BYTES].slice(startIterator.i + 1, endIterator.i + 1);
        }
        return result;
    }
substring ( startIterator , endIterator ) { const result = new Utf8String ( ) ; if ( startIterator === undefined || startIterator === null ) { result [ BYTES ] = this [ BYTES ] . slice ( ) ; } else if ( ! ( startIterator instanceof CodePointsIterator ) ) { error ( 'substring() only accepts code points iterator as arguments' , RangeError ) ; } else if ( endIterator === undefined || endIterator === null ) { result [ BYTES ] = this [ BYTES ] . slice ( startIterator . i + 1 ) ; } else if ( ! ( endIterator instanceof CodePointsIterator ) ) { error ( 'substring() only accepts code points iterator as arguments' , RangeError ) ; } else if ( endIterator . i < startIterator . i ) { error ( 'start of the substring must not be after the end of substring' , RangeError ) ; } else { result [ BYTES ] = this [ BYTES ] . slice ( startIterator . i + 1 , endIterator . i + 1 ) ; } return result ; }
Returns a substring from start iterator to the
 end of the string or to another given iterator.
Returns a substring from start iterator to the end of the string or to another given iterator .