amfUtils.js
function amf0encObject(o) {
    if (typeof o !== 'object') return;

    var data = new Buffer(1);
    data.writeUInt8(0x03,0); // Type object
    var k;
    for (k in o) {
        data = Buffer.concat([data,amf0encUString(k),amf0EncodeOne(o[k])]);
    }
    var termCode = new Buffer(1);
    termCode.writeUInt8(0x09,0);
    return Buffer.concat([data,amf0encUString(''),termCode]);
}
function amf0encObject(o) {
    if (typeof o !== 'object') return;

    var data = new Buffer(1);
    data.writeUInt8(0x03,0); // Type object
    var k;
    for (k in o) {
        data = Buffer.concat([data,amf0encUString(k),amf0EncodeOne(o[k])]);
    }
    var termCode = new Buffer(1);
    termCode.writeUInt8(0x09,0);
    return Buffer.concat([data,amf0encUString(''),termCode]);
}
function amf0encObject ( o ) { if ( typeof o !== 'object' ) return ; var data = new Buffer ( 1 ) ; data . writeUInt8 ( 0x03 , 0 ) ; // Type object var k ; for ( k in o ) { data = Buffer . concat ( [ data , amf0encUString ( k ) , amf0EncodeOne ( o [ k ] ) ] ) ; } var termCode = new Buffer ( 1 ) ; termCode . writeUInt8 ( 0x09 , 0 ) ; return Buffer . concat ( [ data , amf0encUString ( '' ) , termCode ] ) ; }
AMF0 Encode Object
AMF0 Encode Object