<commit_before>flow-tcp-unmarshal
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url]

> Transform stream factory to unmarshal TCP transmitted data.


## Installation

``` bash
$ npm install flow-tcp-unmarshal
```

For use in the browser, use [browserify](https://github.com/substack/node-browserify).


## Usage

To create a stream factory,

``` javascript
var flowFactory = require( 'flow-tcp-unmarshal' );

// Create a new factory:
var flowStream = flowFactory();
```

The factory has the following methods...


#### flow.delimiter( [value] )

This method is a setter/getter. If no `delimiter` is provided, returns the `delimiter` used when delineating streamed data. To set the data `delimiter`,

``` javascript
// String:
flow.delimiter( ' | ' );

// Regular expression:
flow.delimiter( /\r?\n/ );
```

The default `delimiter` is a line feed: `/\r?\n/`.


#### flow.unmarshal( [format] )

This method is a setter/getter. If no `format` is provided, returns the unmarshal `format`. To set the `format`,

``` javascript
flow.unmarshal( 'number' );
```

Available formats include: `json`, `number`, `string`, and `boolean`. The default unmarshal format is `json`.


#### flow.stream()

To create a new stream,

``` javascript
var stream = flowStream.stream();
```


## Notes

When used as setters, all setter/getter methods are chainable. For example,

``` javascript
var flowFactory = require( 'flow-tcp-unmarshal' );

var stream = flowFactory()
	.delimiter( ' | ' )
	.unmarshal( 'number' )
	.stream();
```


## Examples

``` javascript
var eventStream = require( 'event-stream' ),
	streamBuffers = require( 'stream-buffers' ),
	flowFactory = require( 'flow-tcp-unmarshal' );

// Create a readable buffer stream:
var source = new streamBuffers.ReadableStreamBuffer({
	'frequency': 0 // ms; pipe data immediately
});

// Create a stream to unmarshal data:
var unmarshal = flowFactory()
	.delimiter( ' | ' )
	.unmarshal( 'number' )
	.stream();

// Create the pipeline:
source
	.pipe( unmarshal )
	.pipe( eventStream.map( function( d, clbk ){
		clbk( null, d.toString()+'\n' );
	}))
	.pipe( process.stdout );

// Write some data...
var data;
for ( var i = 0; i < 20; i++ ) {
	data = Math.random().toString();
	if ( i < 20-1 ) {
		data += ' | ';
	}
	source.put( data, 'utf8' );
}
```

To run the example code from the top-level application directory,

``` bash
$ node ./examples/index.js
```


## Tests

### Unit

Unit tests use the [Mocha](http://visionmedia.github.io/mocha) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:

``` bash
$ make test
```

All new feature development should have corresponding unit tests to validate correct functionality.


### Test Coverage

This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

``` bash
$ make test-cov
```

Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,

``` bash
$ open reports/coverage/lcov-report/index.html
```


## License

[MIT license](http://opensource.org/licenses/MIT). 

<commit_msg>Update Mocha link<commit_after>flow-tcp-unmarshal
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url]

> Transform stream factory to unmarshal TCP transmitted data.


## Installation

``` bash
$ npm install flow-tcp-unmarshal
```

For use in the browser, use [browserify](https://github.com/substack/node-browserify).


## Usage

To create a stream factory,

``` javascript
var flowFactory = require( 'flow-tcp-unmarshal' );

// Create a new factory:
var flowStream = flowFactory();
```

The factory has the following methods...


#### flow.delimiter( [value] )

This method is a setter/getter. If no `delimiter` is provided, returns the `delimiter` used when delineating streamed data. To set the data `delimiter`,

``` javascript
// String:
flow.delimiter( ' | ' );

// Regular expression:
flow.delimiter( /\r?\n/ );
```

The default `delimiter` is a line feed: `/\r?\n/`.


#### flow.unmarshal( [format] )

This method is a setter/getter. If no `format` is provided, returns the unmarshal `format`. To set the `format`,

``` javascript
flow.unmarshal( 'number' );
```

Available formats include: `json`, `number`, `string`, and `boolean`. The default unmarshal format is `json`.


#### flow.stream()

To create a new stream,

``` javascript
var stream = flowStream.stream();
```


## Notes

When used as setters, all setter/getter methods are chainable. For example,

``` javascript
var flowFactory = require( 'flow-tcp-unmarshal' );

var stream = flowFactory()
	.delimiter( ' | ' )
	.unmarshal( 'number' )
	.stream();
```


## Examples

``` javascript
var eventStream = require( 'event-stream' ),
	streamBuffers = require( 'stream-buffers' ),
	flowFactory = require( 'flow-tcp-unmarshal' );

// Create a readable buffer stream:
var source = new streamBuffers.ReadableStreamBuffer({
	'frequency': 0 // ms; pipe data immediately
});

// Create a stream to unmarshal data:
var unmarshal = flowFactory()
	.delimiter( ' | ' )
	.unmarshal( 'number' )
	.stream();

// Create the pipeline:
source
	.pipe( unmarshal )
	.pipe( eventStream.map( function( d, clbk ){
		clbk( null, d.toString()+'\n' );
	}))
	.pipe( process.stdout );

// Write some data...
var data;
for ( var i = 0; i < 20; i++ ) {
	data = Math.random().toString();
	if ( i < 20-1 ) {
		data += ' | ';
	}
	source.put( data, 'utf8' );
}
```

To run the example code from the top-level application directory,

``` bash
$ node ./examples/index.js
```


## Tests

### Unit

Unit tests use the [Mocha](http://mochajs.org/) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:

``` bash
$ make test
```

All new feature development should have corresponding unit tests to validate correct functionality.


### Test Coverage

This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

``` bash
$ make test-cov
```

Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,

``` bash
$ open reports/coverage/lcov-report/index.html
```


## License

[MIT license](http://opensource.org/licenses/MIT). 


{'fraction_non_alphanumeric': 0.15305971255000742, 'fraction_numerical': 0.002370721588383464, 'mean_word_length': 4.12917933130699, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '3030827', 'n_tokens_mistral': 2269, 'n_tokens_neox': 2077, 'n_words': 686}