amfUtils.js
function amf0decObject(buf) { // TODO: Implement references!
    var obj = {};
    var iBuf = buf.slice(1);
    var len = 1;
//    console.log('ODec',iBuf.readUInt8(0));
    while (iBuf.readUInt8(0) != 0x09) {
        // console.log('Field', iBuf.readUInt8(0), iBuf);
        var prop = amf0decUString(iBuf);
        // console.log('Got field for property', prop);
        len += prop.len;
        if (iBuf.slice(prop.len).readUInt8(0) == 0x09) {
            len++;
            // console.log('Found the end property');
            break;
        } // END Object as value, we shall leave
        if (prop.value == '') break;
        var val = amf0DecodeOne(iBuf.slice(prop.len));
        // console.log('Got field for value', val);
        obj[prop.value] = val.value;
        len += val.len;
        iBuf = iBuf.slice(prop.len + val.len);
    }
    return { len: len, value: obj }
}
function amf0decObject(buf) { // TODO: Implement references!
    var obj = {};
    var iBuf = buf.slice(1);
    var len = 1;
//    console.log('ODec',iBuf.readUInt8(0));
    while (iBuf.readUInt8(0) != 0x09) {
        // console.log('Field', iBuf.readUInt8(0), iBuf);
        var prop = amf0decUString(iBuf);
        // console.log('Got field for property', prop);
        len += prop.len;
        if (iBuf.slice(prop.len).readUInt8(0) == 0x09) {
            len++;
            // console.log('Found the end property');
            break;
        } // END Object as value, we shall leave
        if (prop.value == '') break;
        var val = amf0DecodeOne(iBuf.slice(prop.len));
        // console.log('Got field for value', val);
        obj[prop.value] = val.value;
        len += val.len;
        iBuf = iBuf.slice(prop.len + val.len);
    }
    return { len: len, value: obj }
}
function amf0decObject ( buf ) { // TODO: Implement references! var obj = { } ; var iBuf = buf . slice ( 1 ) ; var len = 1 ; //    console.log('ODec',iBuf.readUInt8(0)); while ( iBuf . readUInt8 ( 0 ) != 0x09 ) { // console.log('Field', iBuf.readUInt8(0), iBuf); var prop = amf0decUString ( iBuf ) ; // console.log('Got field for property', prop); len += prop . len ; if ( iBuf . slice ( prop . len ) . readUInt8 ( 0 ) == 0x09 ) { len ++ ; // console.log('Found the end property'); break ; } // END Object as value, we shall leave if ( prop . value == '' ) break ; var val = amf0DecodeOne ( iBuf . slice ( prop . len ) ) ; // console.log('Got field for value', val); obj [ prop . value ] = val . value ; len += val . len ; iBuf = iBuf . slice ( prop . len + val . len ) ; } return { len : len , value : obj } }
AMF0 Decode Object
@param buf
@returns {{len: number, value: {}}}
AMF0 Decode Object