lib/parsers/substring.js
/**
	 * Parses provided buffer for containing data matching expectations.
	 *
	 * @param {Context} context reference on context for sharing results of parsing
	 * @param {Buffer} buffer slice of data to be parsed
	 * @param {int} atOffset provides offset of provided buffer in context of a larger file or stream
	 * @returns {Promise<ParserResult>}
	 */
Parses provided buffer for containing data matching expectations.
@param {Context} context reference on context for sharing results of parsing
@param {Buffer} buffer slice of data to be parsed
@param {int} atOffset provides offset of provided buffer in context of a larger file or stream
@returns {Promise}
Parses provided buffer for containing data matching expectations . @param { Context } context reference on context for sharing results of parsing @param { Buffer } buffer slice of data to be parsed @param { int } atOffset provides offset of provided buffer in context of a larger file or stream @returns { Promise }
parse( context, buffer, atOffset ) {
		let matchIndex = this._index;
		for ( let read = 0, length = buffer.length; read < length; read++ ) {
			if ( buffer[read] === this._sub[matchIndex] ) {
				matchIndex++;
				if ( matchIndex >= this._sub.length ) {
					this._index = 0;
					const firstIndex = read - matchIndex + 1;
					return this._fullMatch( context, buffer, atOffset, firstIndex, read );
				}
			} else {
				matchIndex = 0;
			}
		}
		this._index = matchIndex;
		return this._partialMatch( buffer, buffer.length - matchIndex );
	}
parse ( context , buffer , atOffset ) { let matchIndex = this . _index ; for ( let read = 0 , length = buffer . length ; read < length ; read ++ ) { if ( buffer [ read ] === this . _sub [ matchIndex ] ) { matchIndex ++ ; if ( matchIndex >= this . _sub . length ) { this . _index = 0 ; const firstIndex = read - matchIndex + 1 ; return this . _fullMatch ( context , buffer , atOffset , firstIndex , read ) ; } } else { matchIndex = 0 ; } } this . _index = matchIndex ; return this . _partialMatch ( buffer , buffer . length - matchIndex ) ; }
Parses provided buffer for containing data matching expectations.
Parses provided buffer for containing data matching expectations .