| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | function readIEEE754(buf, idx, isLE, nl, ml) { | 
					
						
							|  |  |  | 	if(isLE === undefined) isLE = true; | 
					
						
							|  |  |  | 	if(!nl) nl = 8; | 
					
						
							|  |  |  | 	if(!ml && nl === 8) ml = 52; | 
					
						
							|  |  |  | 	var e, m, el = nl * 8 - ml - 1, eMax = (1 << el) - 1, eBias = eMax >> 1; | 
					
						
							|  |  |  | 	var bits = -7, d = isLE ? -1 : 1, i = isLE ? (nl - 1) : 0, s = buf[idx + i]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	i += d; | 
					
						
							|  |  |  | 	e = s & ((1 << (-bits)) - 1); s >>>= (-bits); bits += el; | 
					
						
							|  |  |  | 	for (; bits > 0; e = e * 256 + buf[idx + i], i += d, bits -= 8); | 
					
						
							|  |  |  | 	m = e & ((1 << (-bits)) - 1); e >>>= (-bits); bits += ml; | 
					
						
							|  |  |  | 	for (; bits > 0; m = m * 256 + buf[idx + i], i += d, bits -= 8); | 
					
						
							|  |  |  | 	if (e === eMax) return m ? NaN : ((s ? -1 : 1) * Infinity); | 
					
						
							|  |  |  | 	else if (e === 0) e = 1 - eBias; | 
					
						
							|  |  |  | 	else { m = m + Math.pow(2, ml); e = e - eBias; } | 
					
						
							|  |  |  | 	return (s ? -1 : 1) * m * Math.pow(2, e - ml); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | var __toBuffer, ___toBuffer; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | __toBuffer = ___toBuffer = function toBuffer_(bufs) { var x = []; for(var i = 0; i < bufs[0].length; ++i) { x.push.apply(x, bufs[0][i]); } return x; }; | 
					
						
							|  |  |  | var __double, ___double; | 
					
						
							|  |  |  | __double = ___double = function(b, idx) { return readIEEE754(b, idx);}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var is_buf = function is_buf_a(a) { return Array.isArray(a); }; | 
					
						
							|  |  |  | if(has_buf) { | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	__toBuffer = function(bufs) { return (bufs[0].length > 0 && Buffer.isBuffer(bufs[0][0])) ? Buffer.concat(bufs[0]) : ___toBuffer(bufs);}; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	__double = function double_(b,i) { if(Buffer.isBuffer(b)) return b.readDoubleLE(i); return ___double(b,i); }; | 
					
						
							|  |  |  | 	is_buf = function is_buf_b(a) { return Buffer.isBuffer(a) || Array.isArray(a); }; | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | var __readUInt8 = function(b, idx) { return b[idx]; }; | 
					
						
							|  |  |  | var __readUInt16LE = function(b, idx) { return b[idx+1]*(1<<8)+b[idx]; }; | 
					
						
							|  |  |  | var __readInt16LE = function(b, idx) { var u = b[idx+1]*(1<<8)+b[idx]; return (u < 0x8000) ? u : (0xffff - u + 1) * -1; }; | 
					
						
							|  |  |  | var __readUInt32LE = function(b, idx) { return b[idx+3]*(1<<24)+(b[idx+2]<<16)+(b[idx+1]<<8)+b[idx]; }; | 
					
						
							|  |  |  | var __readInt32LE = function(b, idx) { return (b[idx+3]<<24)|(b[idx+2]<<16)|(b[idx+1]<<8)|b[idx]; }; | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function ReadShift(size, t) { | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	var o="", oo=[], w, vv, i, loc; | 
					
						
							|  |  |  | 	if(t === 'dbcs') { | 
					
						
							|  |  |  | 		loc = this.l; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		if(has_buf && Buffer.isBuffer(this)) o = this.slice(this.l, this.l+2*size).toString("utf16le"); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 		else for(i = 0; i != size; ++i) { o+=String.fromCharCode(__readUInt16LE(this, loc)); loc+=2; } | 
					
						
							|  |  |  | 		size *= 2; | 
					
						
							|  |  |  | 	} else switch(size) { | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 		case 1: o = __readUInt8(this, this.l); break; | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 		case 2: o = (t === 'i' ? __readInt16LE : __readUInt16LE)(this, this.l); break; | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 		case 4: o = __readUInt32LE(this, this.l); break; | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		case 8: if(t === 'f') { o = __double(this, this.l); break; } | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	this.l+=size; return o; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | function WriteShift(t, val, f) { | 
					
						
							|  |  |  | 	var size, i; | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	if(f === 'dbcs') { | 
					
						
							|  |  |  | 		for(i = 0; i != val.length; ++i) this.writeUInt16LE(val.charCodeAt(i), this.l + 2 * i); | 
					
						
							|  |  |  | 		size = 2 * val.length; | 
					
						
							|  |  |  | 	} else switch(t) { | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 		case  1: size = 1; this[this.l] = val&255; break; | 
					
						
							|  |  |  | 		case  3: size = 3; this[this.l+2] = val & 255; val >>>= 8; this[this.l+1] = val&255; val >>>= 8; this[this.l] = val&255; break; | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | 		case  4: size = 4; this.writeUInt32LE(val, this.l); break; | 
					
						
							|  |  |  | 		case  8: size = 8; if(f === 'f') { this.writeDoubleLE(val, this.l); break; } | 
					
						
							|  |  |  | 		/* falls through */ | 
					
						
							|  |  |  | 		case 16: break; | 
					
						
							|  |  |  | 		case -4: size = 4; this.writeInt32LE(val, this.l); break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	this.l += size; return this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | function prep_blob(blob, pos) { | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	blob.l = pos; | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	blob.read_shift = ReadShift; | 
					
						
							|  |  |  | 	blob.write_shift = WriteShift; | 
					
						
							| 
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function parsenoop(blob, length) { blob.l += length; } | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | function writenoop(blob, length) { blob.l += length; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | function new_buf(sz) { | 
					
						
							| 
									
										
										
										
											2014-07-28 13:22:32 +00:00
										 |  |  | 	var o = has_buf ? new Buffer(sz) : new Array(sz); | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | 	prep_blob(o, 0); | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | 	return o; | 
					
						
							| 
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-05-29 22:30:03 +00:00
										 |  |  | 
 |