API Docs for: 0.0.1
Show:

StringParser Class

Extends Parser
Module: niviz

A simple string/stream parser.

Constructor

StringParser

(
  • [data='']
  • [delimiter='\n']
  • [trim='\r']
)

Parameters:

  • [data=''] String optional

    The data to parse.

  • [delimiter='\n'] String optional

    The token delimiter.

  • [trim='\r'] String optional

    The token trim value.

Methods

check

(
  • against
)
Boolean

Returns true if the next line starts with the given string against.

Parameters:

Returns:

end

() chainable

Inherited from Parser: lib/parser.js:176

This method must be called by the parsing methods when the parsing has finished.

next

() String | Undefined

Returns the next line/token; updates the parser's current position pointer and line number as a side effect.

Returns:

String | Undefined:

The next token.

parse

(
  • [callback]
)
Object

Inherited from Parser but overwritten in lib/parser.js:130

Starts the parsing process; in sync mode this method blocks until the parsing has finished, otherwise it should return immediately! If given a callback, it must be bound to the end and error events.

Parameters:

Returns:

Object: The parse result.

parse_line

(
  • line
)
chainable

Parses a single line. This method should be implemented by all subclasses.

Parameters:

  • line String

    The line to parse.

pause

()

Resumes _parse method after a short timeout; these small timeouts effectively give the browser more time to breathe and are a remedy for the 'long running script' warnings in Firefox.

peek

() String

Returns:

String:

The next k characters.

skip

(
  • over
  • [until]
)
String | Undefined

Like next() but skips lines matching over until the end of data is reached or, if given, the next line starts with until.

Parameters:

Returns:

String | Undefined:

The next line.

verify

() chainable

Inherited from Parser: lib/parser.js:165

Verify that all syntactic and semantic requirements are met by the parsed entity.

Properties

_parse

Unknown

data

Object

Inherited from Parser: lib/parser.js:50

delimiter

String

The token delimiter; defaults to a newline.

done

Boolean

Whether or not all data has been parsed.

lines

Number private

The number of lines/tokens parsed so far.

position

Number private

The current position in the input data.

result

Object

Inherited from Parser: lib/parser.js:56

trim

String

The token trim value; defaults to a carriage return. If present, this value will be cut off at the end of each token during parsing.