Skip to content

Commit

Permalink
[minor] Added docs for the Parser#reset method
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Feb 1, 2013
1 parent 3e2ee44 commit d35f3d8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
- [The response event][3.3.1]
- [The error:response event][3.3.2]
- [The error event][3.3.3]
- [Finishing it up][3.4]
- [Resetting the parsers internal state][3.4]
- [Finishing it up][3.5]
- [Contributing][4]
- [License][5]

Expand Down Expand Up @@ -168,6 +169,20 @@ parser.on('error', function error(err) {
});
```

#### Resetting the parsers internal state

To make it possible to re-use parsers, theres a reset method that will reset the
internals back to the same state as it as when it was freshly initialized.
Please note that the reset method does not remove the assigned event listeners.

```js
// reset internals
parser.reset();

// also nuke the eventListeners
parser.removeAllListeners();
```

#### Finishing it up

Once you are done with parsing you can terminate it by calling:
Expand Down Expand Up @@ -199,6 +214,7 @@ MIT
[3.3.1]: #the-response-event
[3.3.2]: #the-errorresponse-event
[3.3.3]: #the-error-event
[3.4]: #resetting-the-parsers-internal-state
[3.4]: #finishing-it-up
[4]: /3rd-Eden/memcached-stream/blob/master/CONTRIBUTING.md
[5]: #license
Expand Down

0 comments on commit d35f3d8

Please sign in to comment.