index.js
function prepareData(items, with_timestamps, with_ns) {
    var data = {
        request: 'sender data',
        data: items
    };

    if (with_timestamps) {
        var ts = Date.now() / 1000;
        data.clock = ts | 0;

        if (with_ns) {
            data.ns = (ts % 1) * 1000 * 1000000 | 0;
        }
    }

    var payload = new Buffer(JSON.stringify(data), 'utf8'),
        header  = new Buffer(5 + 4); // ZBXD\1 + packed payload.length

    header.write('ZBXD\x01');
    header.writeInt32LE(payload.length, 5);
    return Buffer.concat([header, new Buffer('\x00\x00\x00\x00'), payload]);
}
function prepareData(items, with_timestamps, with_ns) {
    var data = {
        request: 'sender data',
        data: items
    };

    if (with_timestamps) {
        var ts = Date.now() / 1000;
        data.clock = ts | 0;

        if (with_ns) {
            data.ns = (ts % 1) * 1000 * 1000000 | 0;
        }
    }

    var payload = new Buffer(JSON.stringify(data), 'utf8'),
        header  = new Buffer(5 + 4); // ZBXD\1 + packed payload.length

    header.write('ZBXD\x01');
    header.writeInt32LE(payload.length, 5);
    return Buffer.concat([header, new Buffer('\x00\x00\x00\x00'), payload]);
}
function prepareData ( items , with_timestamps , with_ns ) { var data = { request : 'sender data' , data : items } ; if ( with_timestamps ) { var ts = Date . now ( ) / 1000 ; data . clock = ts | 0 ; if ( with_ns ) { data . ns = ( ts % 1 ) * 1000 * 1000000 | 0 ; } } var payload = new Buffer ( JSON . stringify ( data ) , 'utf8' ) , header = new Buffer ( 5 + 4 ) ; // ZBXD\1 + packed payload.length header . write ( 'ZBXD\x01' ) ; header . writeInt32LE ( payload . length , 5 ) ; return Buffer . concat ( [ header , new Buffer ( '\x00\x00\x00\x00' ) , payload ] ) ; }
takes items array and prepares payload for sending
takes items array and prepares payload for sending