main.js
function ANSIState(legacy) {

    var feed = '',
        last_match = '',
        stream_match = [],
        _this = this;

    PassThrough.call(this);

    this.attrs = {};
    this.reset();
    this.is_reset = false;
    this.setEncoding('utf8');

    this.on('data', function(chunk) {
        feed += chunk;
        if (feed.indexOf('\033') === -1) {
            feed = '';
        } else {
            stream_match = feed.match(color_regex);
            if (stream_match.length > 0) {
                last_match = stream_match[stream_match.length - 1];
                feed = feed.slice(feed.lastIndexOf(last_match) + last_match.length);
                _this.updateWithArray(stream_match);
            }
        }
    });

    if (legacy !== undefined) {
        this.update(legacy);
    }
}
function ANSIState(legacy) {

    var feed = '',
        last_match = '',
        stream_match = [],
        _this = this;

    PassThrough.call(this);

    this.attrs = {};
    this.reset();
    this.is_reset = false;
    this.setEncoding('utf8');

    this.on('data', function(chunk) {
        feed += chunk;
        if (feed.indexOf('\033') === -1) {
            feed = '';
        } else {
            stream_match = feed.match(color_regex);
            if (stream_match.length > 0) {
                last_match = stream_match[stream_match.length - 1];
                feed = feed.slice(feed.lastIndexOf(last_match) + last_match.length);
                _this.updateWithArray(stream_match);
            }
        }
    });

    if (legacy !== undefined) {
        this.update(legacy);
    }
}
function ANSIState ( legacy ) { var feed = '' , last_match = '' , stream_match = [ ] , _this = this ; PassThrough . call ( this ) ; this . attrs = { } ; this . reset ( ) ; this . is_reset = false ; this . setEncoding ( 'utf8' ) ; this . on ( 'data' , function ( chunk ) { feed += chunk ; if ( feed . indexOf ( '\033' ) === - 1 ) { feed = '' ; } else { stream_match = feed . match ( color_regex ) ; if ( stream_match . length > 0 ) { last_match = stream_match [ stream_match . length - 1 ] ; feed = feed . slice ( feed . lastIndexOf ( last_match ) + last_match . length ) ; _this . updateWithArray ( stream_match ) ; } } } ) ; if ( legacy !== undefined ) { this . update ( legacy ) ; } }
ANSI state constructor
ANSI state constructor