<commit_before># imap-parser

IMAP command parser for use on both client and server.  This is based on work in [andris9/inbox](https://github.com/andris9/inbox) and provides a parser for IMAP line based commands.

[![Build Status](https://travis-ci.org/hashmail/imap-parser.png?branch=master)](https://travis-ci.org/hashmail/imap-parser)

## Installation

```
$ npm install imap-parser
```

## API

To create an instance of the line parser:

```js
var Parser = require('imap-parser')
var parser = new Parser()
```

The parser is a writable & readable stream.  Just pipe the data stream from the TCP connection in and read the parsed lines out as `data` events.  Each data event contains an array with the parsed data for a line.  String literals are also handled more or less automatically (see caviat in events).

### Events

#### log

Is emitted with a string as its data.  This string is the entire unparsed content of the line.  It is useful for logging:

```js
parser.on('log', function (line) {
  console.log('c: ' + line)
})

#### literal

Is emitted when the client is sending a literal to the server but is waiting for a command continuation request:

```js
parser.on('literal', function () {
  connection.write('+ Ready for additional command text')
})
```

## Licence

MIT<commit_msg>Fix typo in readme<commit_after># imap-parser

IMAP command parser for use on both client and server.  This is based on work in [andris9/inbox](https://github.com/andris9/inbox) and provides a parser for IMAP line based commands.

[![Build Status](https://travis-ci.org/hashmail/imap-parser.png?branch=master)](https://travis-ci.org/hashmail/imap-parser)

## Installation

```
$ npm install imap-parser
```

## API

To create an instance of the line parser:

```js
var Parser = require('imap-parser')
var parser = new Parser()
```

The parser is a writable & readable stream.  Just pipe the data stream from the TCP connection in and read the parsed lines out as `data` events.  Each data event contains an array with the parsed data for a line.  String literals are also handled more or less automatically (see caviat in events).

### Events

#### log

Is emitted with a string as its data.  This string is the entire unparsed content of the line.  It is useful for logging:

```js
parser.on('log', function (line) {
  console.log('c: ' + line)
})
```

#### literal

Is emitted when the client is sending a literal to the server but is waiting for a command continuation request:

```js
parser.on('literal', function () {
  connection.write('+ Ready for additional command text')
})
```

## Licence

MIT
{'fraction_non_alphanumeric': 0.1104270873412851, 'fraction_numerical': 0.0015390534821085034, 'mean_word_length': 4.168986083499006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '273011', 'n_tokens_mistral': 787, 'n_tokens_neox': 763, 'n_words': 334}