# Class: Parser

## Parser

#### new Parser()

A parser for M3U8 files. The current interpretation of the input is exposed as a property `manifest` on parser objects. It's just two lines to create and parse a manifest once you have the contents available as a string: ```js var parser = new videojs.m3u8.Parser(); parser.push(xhr.responseText); ``` New input can later be applied to update the manifest object by calling `push` again. The parser attempts to create a usable manifest object even if the underlying input is somewhat nonsensical. It emits `info` and `warning` events during the parse if it encounters input that seems invalid or requires some property of the manifest object to be defaulted.

Source:
  - m3u8/parser.js, line 9

### Extends

- Stream

### Methods

#### dispose()

Destroys the stream and cleans up.

Inherited From:
  - Stream#dispose
Source:
  - stream.js, line 84

#### end()

Flush any remaining input. This can be handy if the last line of an M3U8 manifest did not contain a trailing newline but the file has been completely received.

Source:
  - m3u8/parser.js, line 312

#### off(type, listener) → {Boolean}

Remove a listener for a specified event type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name
`listener` | function | a function previously registered for this type of event through `on`

Inherited From:
  - Stream#off
Source:
  - stream.js, line 36

##### Returns:

if we could turn it off or not

Type
  Boolean

#### on(type, listener)

Add a listener for a specified event type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name
`listener` | function | the callback to be invoked when an event of the specified type occurs

Inherited From:
  - Stream#on
Source:
  - stream.js, line 21

#### pipe(destination)

Forwards all `data` events on this stream to the destination stream. The destination stream should provide a method `push` to receive the data events as they arrive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | Stream | the stream that will receive all `data` events

Inherited From:
  - Stream#pipe
Source:
  - stream.js, line 95
See:
  - http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options

#### push(chunk)

Parse the input string and update the manifest object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`chunk` | String | a potentially incomplete portion of the manifest

Source:
  - m3u8/parser.js, line 303

#### trigger(type)

Trigger an event of the specified type on this stream. Any additional arguments to this function are passed as parameters to event listeners.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name

Inherited From:
  - Stream#trigger
Source:
  - stream.js, line 53