| 96 | } |
| 97 | |
| 98 | public parse() { |
| 99 | const prefix = this._view.getUint8(this._offset++); |
| 100 | let value, |
| 101 | length = 0, |
| 102 | type = 0, |
| 103 | hi = 0, |
| 104 | lo = 0; |
| 105 | |
| 106 | if (prefix < 0xc0) { |
| 107 | // positive fixint |
| 108 | if (prefix < 0x80) { |
| 109 | return prefix; |
| 110 | } |
| 111 | // fixmap |
| 112 | if (prefix < 0x90) { |
| 113 | return this._map(prefix & 0x0f); |
| 114 | } |
| 115 | // fixarray |
| 116 | if (prefix < 0xa0) { |
| 117 | return this._array(prefix & 0x0f); |
| 118 | } |
| 119 | // fixstr |
| 120 | return this._str(prefix & 0x1f); |
| 121 | } |
| 122 | |
| 123 | // negative fixint |
| 124 | if (prefix > 0xdf) { |
| 125 | return (0xff - prefix + 1) * -1; |
| 126 | } |
| 127 | |
| 128 | switch (prefix) { |
| 129 | // nil |
| 130 | case 0xc0: |
| 131 | return null; |
| 132 | // false |
| 133 | case 0xc2: |
| 134 | return false; |
| 135 | // true |
| 136 | case 0xc3: |
| 137 | return true; |
| 138 | |
| 139 | // bin |
| 140 | |
| 141 | case 0xc4: |
| 142 | length = this._view.getUint8(this._offset); |
| 143 | this._offset += 1; |
| 144 | return this._bin(length); |
| 145 | case 0xc5: |
| 146 | length = this._view.getUint16(this._offset); |
| 147 | this._offset += 2; |
| 148 | return this._bin(length); |
| 149 | case 0xc6: |
| 150 | length = this._view.getUint32(this._offset); |
| 151 | this._offset += 4; |
| 152 | return this._bin(length); |
| 153 | |
| 154 | // ext |
| 155 | |