<commit_before>var Parser = require('../lib/binary_parser').Parser;

var tcpHeader = new Parser()
    .endianess('big')
    .uint16('srcPort')
    .uint16('dstPort')
    .uint32('seq')
    .uint32('ack')
    .bit4('dataOffset')
    .bit6('reserved')
    .bit1('urg')
    .bit1('ack')
    .bit1('psh')
    .bit1('rst')
    .bit1('syn')
    .bit1('fin')
    .uint16('windowSize')
    .uint16('checksum')
    .uint16('urgentPointer');

var buf = new Buffer('e8a203e108e177e13d20756b801829d3004100000101080a2ea486ba793310bc', 'hex');

console.log(tcpHeader.parse(buf));<commit_msg>Changed flags to be nested<commit_after>var Parser = require('../lib/binary_parser').Parser;

var tcpHeader = new Parser()
    .endianess('big')
    .uint16('srcPort')
    .uint16('dstPort')
    .uint32('seq')
    .uint32('ack')
    .bit4('dataOffset')
    .bit6('reserved')
    .nest('flags', {
        type: new Parser()
            .bit1('urg')
            .bit1('ack')
            .bit1('psh')
            .bit1('rst')
            .bit1('syn')
            .bit1('fin')
    })
    .uint16('windowSize')
    .uint16('checksum')
    .uint16('urgentPointer');

var buf = new Buffer('e8a203e108e177e13d20756b801829d3004100000101080a2ea486ba793310bc', 'hex');

console.log(tcpHeader.parse(buf));
{'fraction_non_alphanumeric': 0.18818897637795276, 'fraction_numerical': 0.11181102362204724, 'mean_word_length': 2.99685534591195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5646150', 'n_tokens_mistral': 555, 'n_tokens_neox': 477, 'n_words': 65}