Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

3
node_modules/bytebuffer/.npmignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
npm-debug.log
.idea/

5
node_modules/bytebuffer/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.12
- 4.2
sudo: false

202
node_modules/bytebuffer/LICENSE generated vendored Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

64
node_modules/bytebuffer/README.md generated vendored Normal file
View File

@ -0,0 +1,64 @@
![bytebuffer.js - The swiss army knife for binary data in JavaScript.](https://raw.github.com/dcodeIO/bytebuffer.js/master/bytebuffer.png)
======================================
A fast and complete ByteBuffer implementation using either ArrayBuffers in the browser or node Buffers under node.js,
generated from a single source tree through [MetaScript](https://github.com/dcodeIO/MetaScript).
[![Build Status](https://travis-ci.org/dcodeIO/bytebuffer.js.svg?branch=master)](https://travis-ci.org/dcodeIO/bytebuffer.js)
[![Donate](https://raw.githubusercontent.com/dcodeIO/bytebuffer.js/master/donate.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=%3C3%20bytebuffer.js)
Features
--------
* Three API-compatible versions:
* **bytebuffer**   Backing buffer: ArrayBuffer, Accessor: Uint8Array
* **bytebuffer-dataview**   Backing buffer: ArrayBuffer, Accessor: DataView
* **bytebuffer-node**   Backing buffer / Accessor: node Buffer
* 8, 16, 32 and 64 bit (through [long.js](https://github.com/dcodeIO/long.js)) signed and unsigned integers
* 32 and 64 bit floats
* Varints as used in protobuf (32 and 64 bit, zig-zag)
* [Base64](https://github.com/dcodeIO/lxiv), [utf8](https://github.com/dcodeIO/utfx), binary, hex and debug encodings
* Handy string and debugging utilities
* Big and little endianness
* Relative and absolute zero-copy operations wherever possible
* Transparent resizing when using unknown-length data
* Chaining of all operations that do not return a specific value
* Slicing, appending, prepending, reversing, flip, mark, reset, etc.
Usage
-----
The library is compatible with CommonJS and AMD loaders and is exposed globally as `dcodeIO.ByteBuffer` if neither is
available.
```javascript
var ByteBuffer = require("bytebuffer");
var bb = new ByteBuffer()
.writeIString("Hello world!")
.flip();
console.log(bb.readIString()+" from bytebuffer.js");
```
In the browser, 64 bit integer support is optional and present only if [Long.js](https://github.com/dcodeIO/long.js) has
been loaded prior to bytebuffer.js.
API
---
* [View the API documentation](https://github.com/dcodeIO/bytebuffer.js/wiki/API)
* [Check the wiki](https://github.com/dcodeIO/bytebuffer.js/wiki)
Downloads
---------
* [Distributions](https://github.com/dcodeIO/bytebuffer.js/tree/master/dist)
* [ZIP-Archive](https://github.com/dcodeIO/bytebuffer.js/archive/master.zip)
* [Tarball](https://github.com/dcodeIO/bytebuffer.js/tarball/master)
Support for IE<10, FF<15, Chrome<9 etc.
---------------------------------------
* Use bytebuffer-dataview with a polyfill ([see](https://github.com/dcodeIO/bytebuffer.js/tree/master/dist))
Contributors
------------
[Dretch](https://github.com/Dretch) (IE8 compatibility)
License
-------
**License:** [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) - Logo derived from [W3C HTML5 Logos](http://www.w3.org/html/logo/) (CC A 3.0)

12
node_modules/bytebuffer/bower.json generated vendored Normal file
View File

@ -0,0 +1,12 @@
{
"name": "bytebuffer",
"version": "5.0.1",
"author": "Daniel Wirtz <dcode@dcode.io>",
"description": "A full-featured ByteBuffer implementation using typed arrays.",
"main": "dist/bytebuffer.js",
"keywords": ["net", "array", "buffer", "arraybuffer", "typed array", "bytebuffer", "json", "websocket", "webrtc"],
"dependencies": {
"long": "latest"
},
"license": "Apache-2.0"
}

BIN
node_modules/bytebuffer/bytebuffer.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

47
node_modules/bytebuffer/dist/README.md generated vendored Normal file
View File

@ -0,0 +1,47 @@
Distributions
=============
ByteBuffer.js uses either ArrayBuffers in the browser or Buffers under node.js.
### Browser: [ArrayBuffer](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)-backed
##### Accessed through Typed Arrays
Using Typed Arrays here is pretty much ideal, but it [requires a somewhat recent browser](http://caniuse.com/#feat=typedarrays).
* **[bytebuffer.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer.js)**
uses an ArrayBuffer as its backing buffer, accessed through an [Uint8Array](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
* **[bytebuffer.min.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer.min.js)**
has been compiled with Closure Compiler using advanced optimizations.
* **[bytebuffer.min.js.gz](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer.min.js.gz)**
has also been gzipped using `-9`.
* **[bytebuffer.min.map](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer.min.map)**
is the source map generated by Closure Compiler.
##### Accessed through a DataView ([polyfill](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js) compatible)
Using DataViews is [generally slower](https://github.com/dcodeIO/ByteBuffer.js/issues/16) but works well with common polyfills for
older browsers (avoids array access operators on Typed Arrays).
* **[bytebuffer-dataview.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer-dataview.js)**
uses an ArrayBuffer as its backing buffer, accessed through a [DataView](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/DataView).
* **[bytebuffer-dataview.min.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer-dataview.min.js)**
has been compiled with Closure Compiler using advanced optimizations.
* **[bytebuffer-dataview.min.js.gz](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer-dataview.min.js.gz)**
has also been gzipped using `-9`.
* **[bytebuffer-dataview.min.map](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer-dataview.min.map)**
is the source map generated by Closure Compiler.
### node.js: [Buffer](https://nodejs.org/api/buffer.html)-backed
* **[bytebuffer-node.js](https://raw.githubusercontent.com/dcodeIO/ByteBuffer.js/master/dist/bytebuffer-node.js)**
uses a [node Buffer](https://nodejs.org/api/buffer.html) as its backing buffer and accessor.
Also available as `bytebuffer` on [npm](https://www.npmjs.org/package/bytebuffer) and
[bower](http://bower.io/search/?q=bytebuffer).

3461
node_modules/bytebuffer/dist/bytebuffer-dataview.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,88 @@
/*
bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
Backing buffer: ArrayBuffer, Accessor: DataView
Released under the Apache License, Version 2.0
see: https://github.com/dcodeIO/bytebuffer.js for details
*/
(function(h,m){if("function"===typeof define&&define.amd)define(["long"],m);else if("function"===typeof require&&"object"===typeof module&&module&&module.exports){var s=module,f;try{f=require("long")}catch(d){}f=m(f);s.exports=f}else(h.dcodeIO=h.dcodeIO||{}).ByteBuffer=m(h.dcodeIO.Long)})(this,function(h){function m(a){var b=0;return function(){return b<a.length?a.charCodeAt(b++):null}}function s(){var a=[],b=[];return function(){if(0===arguments.length)return b.join("")+u.apply(String,a);1024<a.length+
arguments.length&&(b.push(u.apply(String,a)),a.length=0);Array.prototype.push.apply(a,arguments)}}var f=function(a,b,c){"undefined"===typeof a&&(a=f.DEFAULT_CAPACITY);"undefined"===typeof b&&(b=f.DEFAULT_ENDIAN);"undefined"===typeof c&&(c=f.DEFAULT_NOASSERT);if(!c){a|=0;if(0>a)throw RangeError("Illegal capacity");b=!!b;c=!!c}this.buffer=0===a?t:new ArrayBuffer(a);this.view=0===a?null:new DataView(this.buffer);this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian=b;this.noAssert=c};f.VERSION=
"5.0.1";f.LITTLE_ENDIAN=!0;f.BIG_ENDIAN=!1;f.DEFAULT_CAPACITY=16;f.DEFAULT_ENDIAN=f.BIG_ENDIAN;f.DEFAULT_NOASSERT=!1;f.Long=h||null;var d=f.prototype;Object.defineProperty(d,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var t=new ArrayBuffer(0),u=String.fromCharCode;f.accessor=function(){return DataView};f.allocate=function(a,b,c){return new f(a,b,c)};f.concat=function(a,b,c,e){if("boolean"===typeof b||"string"!==typeof b)e=c,c=b,b=void 0;for(var k=0,d=0,g=a.length,p;d<g;++d)f.isByteBuffer(a[d])||
(a[d]=f.wrap(a[d],b)),p=a[d].limit-a[d].offset,0<p&&(k+=p);if(0===k)return new f(0,c,e);b=new f(k,c,e);e=new Uint8Array(b.buffer);for(d=0;d<g;)c=a[d++],p=c.limit-c.offset,0>=p||(e.set((new Uint8Array(c.buffer)).subarray(c.offset,c.limit),b.offset),b.offset+=p);b.limit=b.offset;b.offset=0;return b};f.isByteBuffer=function(a){return!0===(a&&a.__isByteBuffer__)};f.type=function(){return ArrayBuffer};f.wrap=function(a,b,c,e){"string"!==typeof b&&(e=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===
typeof b&&(b="utf8"),b){case "base64":return f.fromBase64(a,c);case "hex":return f.fromHex(a,c);case "binary":return f.fromBinary(a,c);case "utf8":return f.fromUTF8(a,c);case "debug":return f.fromDebug(a,c);default:throw Error("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw TypeError("Illegal buffer");if(f.isByteBuffer(a))return b=d.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new f(0,c,e),0<a.length&&(b.buffer=a.buffer,b.offset=a.byteOffset,b.limit=a.byteOffset+
a.byteLength,b.view=new DataView(a.buffer));else if(a instanceof ArrayBuffer)b=new f(0,c,e),0<a.byteLength&&(b.buffer=a,b.offset=0,b.limit=a.byteLength,b.view=0<a.byteLength?new DataView(a):null);else if("[object Array]"===Object.prototype.toString.call(a))for(b=new f(a.length,c,e),b.limit=a.length,c=0;c<a.length;++c)b.view.setUint8(c,a[c]);else throw TypeError("Illegal buffer");return b};d.writeBitSet=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if(!(a instanceof
Array))throw TypeError("Illegal BitSet: Not an array");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var e=b,k=a.length,d=k>>3,g=0,f;for(b+=this.writeVarint32(k,b);d--;)f=!!a[g++]&1|(!!a[g++]&1)<<1|(!!a[g++]&1)<<2|(!!a[g++]&1)<<3|(!!a[g++]&1)<<4|(!!a[g++]&1)<<5|(!!a[g++]&1)<<6|(!!a[g++]&1)<<7,this.writeByte(f,b++);if(g<k){for(f=d=0;g<
k;)f|=(!!a[g++]&1)<<d++;this.writeByte(f,b++)}return c?(this.offset=b,this):b-e};d.readBitSet=function(a){var b="undefined"===typeof a;b&&(a=this.offset);var c=this.readVarint32(a),e=c.value,k=e>>3,d=0,g=[];for(a+=c.length;k--;)c=this.readByte(a++),g[d++]=!!(c&1),g[d++]=!!(c&2),g[d++]=!!(c&4),g[d++]=!!(c&8),g[d++]=!!(c&16),g[d++]=!!(c&32),g[d++]=!!(c&64),g[d++]=!!(c&128);if(d<e)for(k=0,c=this.readByte(a++);d<e;)g[d++]=!!(c>>k++&1);b&&(this.offset=a);return g};d.readBytes=function(a,b){var c="undefined"===
typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+"+a+") <= "+this.buffer.byteLength);}var e=this.slice(b,b+a);c&&(this.offset+=a);return e};d.writeBytes=d.append;d.writeInt8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");
a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setInt8(b-1,a);c&&(this.offset+=1);return this};d.writeByte=d.writeInt8;d.readInt8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+
a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getInt8(a);b&&(this.offset+=1);return a};d.readByte=d.readInt8;d.writeUint8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=
0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setUint8(b-1,a);c&&(this.offset+=1);return this};d.writeUInt8=d.writeUint8;d.readUint8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
a+" (+1) <= "+this.buffer.byteLength);}a=this.view.getUint8(a);b&&(this.offset+=1);return a};d.readUInt8=d.readUint8;d.writeInt16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);
}b+=2;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setInt16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};d.writeShort=d.writeInt16;d.readInt16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getInt16(a,this.littleEndian);
b&&(this.offset+=2);return a};d.readShort=d.readInt16;d.writeUint16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var e=this.buffer.byteLength;b>e&&this.resize((e*=
2)>b?e:b);this.view.setUint16(b-2,a,this.littleEndian);c&&(this.offset+=2);return this};d.writeUInt16=d.writeUint16;d.readUint16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}a=this.view.getUint16(a,this.littleEndian);b&&(this.offset+=2);return a};d.readUInt16=
d.readUint16;d.writeInt32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setInt32(b-4,
a,this.littleEndian);c&&(this.offset+=4);return this};d.writeInt=d.writeInt32;d.readInt32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getInt32(a,this.littleEndian);b&&(this.offset+=4);return a};d.readInt=d.readInt32;d.writeUint32=function(a,b){var c=
"undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setUint32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};
d.writeUInt32=d.writeUint32;d.readUint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getUint32(a,this.littleEndian);b&&(this.offset+=4);return a};d.readUInt32=d.readUint32;h&&(d.writeInt64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);
if(!this.noAssert){if("number"===typeof a)a=h.fromNumber(a);else if("string"===typeof a)a=h.fromString(a);else if(!(a&&a instanceof h))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=h.fromNumber(a):"string"===typeof a&&(a=h.fromString(a));b+=8;var e=
this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,a.low,!1));c&&(this.offset+=8);return this},d.writeLong=d.writeInt64,d.readInt64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new h(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!1):new h(this.view.getInt32(a+4,!1),this.view.getInt32(a,!1),!1);b&&(this.offset+=8);return a},d.readLong=d.readInt64,d.writeUint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=h.fromNumber(a);else if("string"===typeof a)a=h.fromString(a);else if(!(a&&a instanceof h))throw TypeError("Illegal value: "+a+" (not an integer or Long)");
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=h.fromNumber(a):"string"===typeof a&&(a=h.fromString(a));b+=8;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=8;this.littleEndian?(this.view.setInt32(b,a.low,!0),this.view.setInt32(b+4,a.high,!0)):(this.view.setInt32(b,a.high,!1),this.view.setInt32(b+4,
a.low,!1));c&&(this.offset+=8);return this},d.writeUInt64=d.writeUint64,d.readUint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.littleEndian?new h(this.view.getInt32(a,!0),this.view.getInt32(a+4,!0),!0):new h(this.view.getInt32(a+4,!1),this.view.getInt32(a,
!1),!0);b&&(this.offset+=8);return a},d.readUInt64=d.readUint64);d.writeFloat32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var e=this.buffer.byteLength;b>e&&this.resize((e*=
2)>b?e:b);this.view.setFloat32(b-4,a,this.littleEndian);c&&(this.offset+=4);return this};d.writeFloat=d.writeFloat32;d.readFloat32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=this.view.getFloat32(a,this.littleEndian);b&&(this.offset+=4);return a};d.readFloat=
d.readFloat32;d.writeFloat64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=8;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);this.view.setFloat64(b-8,a,this.littleEndian);
c&&(this.offset+=8);return this};d.writeDouble=d.writeFloat64;d.readFloat64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=this.view.getFloat64(a,this.littleEndian);b&&(this.offset+=8);return a};d.readDouble=d.readFloat64;f.MAX_VARINT32_BYTES=5;f.calculateVarint32=
function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};f.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};f.zigZagDecode32=function(a){return a>>>1^-(a&1)|0};d.writeVarint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+0) <= "+this.buffer.byteLength);}var e=f.calculateVarint32(a),k;b+=e;k=this.buffer.byteLength;b>k&&this.resize((k*=2)>b?k:b);b-=e;for(a>>>=0;128<=a;)k=a&127|128,this.view.setUint8(b++,k),a>>>=7;this.view.setUint8(b++,a);return c?(this.offset=b,this):e};d.writeVarint32ZigZag=function(a,b){return this.writeVarint32(f.zigZagEncode32(a),b)};d.readVarint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+
a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=0,e=0,k;do{if(!this.noAssert&&a>this.limit)throw a=Error("Truncated"),a.truncated=!0,a;k=this.view.getUint8(a++);5>c&&(e|=(k&127)<<7*c);++c}while(0!==(k&128));e|=0;return b?(this.offset=a,e):{value:e,length:c}};d.readVarint32ZigZag=function(a){a=this.readVarint32(a);"object"===typeof a?a.value=f.zigZagDecode32(a.value):a=f.zigZagDecode32(a);return a};
h&&(f.MAX_VARINT64_BYTES=10,f.calculateVarint64=function(a){"number"===typeof a?a=h.fromNumber(a):"string"===typeof a&&(a=h.fromString(a));var b=a.toInt()>>>0,c=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==c?16384>b?128>b?1:2:2097152>b?3:4:16384>c?128>c?5:6:2097152>c?7:8:128>a?9:10},f.zigZagEncode64=function(a){"number"===typeof a?a=h.fromNumber(a,!1):"string"===typeof a?a=h.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},
f.zigZagDecode64=function(a){"number"===typeof a?a=h.fromNumber(a,!1):"string"===typeof a?a=h.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftRightUnsigned(1).xor(a.and(h.ONE).toSigned().negate()).toSigned()},d.writeVarint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=h.fromNumber(a);else if("string"===typeof a)a=h.fromString(a);else if(!(a&&a instanceof h))throw TypeError("Illegal value: "+a+" (not an integer or Long)");
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=h.fromNumber(a,!1):"string"===typeof a?a=h.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());var e=f.calculateVarint64(a),k=a.toInt()>>>0,d=a.shiftRightUnsigned(28).toInt()>>>0,g=a.shiftRightUnsigned(56).toInt()>>>0;b+=e;var p=this.buffer.byteLength;b>p&&this.resize((p*=
2)>b?p:b);b-=e;switch(e){case 10:this.view.setUint8(b+9,g>>>7&1);case 9:this.view.setUint8(b+8,9!==e?g|128:g&127);case 8:this.view.setUint8(b+7,8!==e?d>>>21|128:d>>>21&127);case 7:this.view.setUint8(b+6,7!==e?d>>>14|128:d>>>14&127);case 6:this.view.setUint8(b+5,6!==e?d>>>7|128:d>>>7&127);case 5:this.view.setUint8(b+4,5!==e?d|128:d&127);case 4:this.view.setUint8(b+3,4!==e?k>>>21|128:k>>>21&127);case 3:this.view.setUint8(b+2,3!==e?k>>>14|128:k>>>14&127);case 2:this.view.setUint8(b+1,2!==e?k>>>7|128:
k>>>7&127);case 1:this.view.setUint8(b,1!==e?k|128:k&127)}return c?(this.offset+=e,this):e},d.writeVarint64ZigZag=function(a,b){return this.writeVarint64(f.zigZagEncode64(a),b)},d.readVarint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,e=0,k=0,d=
0,g=0,g=this.view.getUint8(a++),e=g&127;if(g&128&&(g=this.view.getUint8(a++),e|=(g&127)<<7,g&128&&(g=this.view.getUint8(a++),e|=(g&127)<<14,g&128&&(g=this.view.getUint8(a++),e|=(g&127)<<21,g&128&&(g=this.view.getUint8(a++),k=g&127,g&128&&(g=this.view.getUint8(a++),k|=(g&127)<<7,g&128&&(g=this.view.getUint8(a++),k|=(g&127)<<14,g&128&&(g=this.view.getUint8(a++),k|=(g&127)<<21,g&128&&(g=this.view.getUint8(a++),d=g&127,g&128&&(g=this.view.getUint8(a++),d|=(g&127)<<7,g&128))))))))))throw Error("Buffer overrun");
e=h.fromBits(e|k<<28,k>>>4|d<<24,!1);return b?(this.offset=a,e):{value:e,length:a-c}},d.readVarint64ZigZag=function(a){(a=this.readVarint64(a))&&a.value instanceof h?a.value=f.zigZagDecode64(a.value):a=f.zigZagDecode64(a);return a});d.writeCString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);var e,d=a.length;if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");for(e=0;e<d;++e)if(0===a.charCodeAt(e))throw RangeError("Illegal str: Contains NULL-characters");
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}d=n.calculateUTF16asUTF8(m(a))[1];b+=d+1;e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=d+1;n.encodeUTF16toUTF8(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));this.view.setUint8(b++,0);return c?(this.offset=b,this):d};d.readCString=function(a){var b="undefined"===typeof a;
b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,e,d=-1;n.decodeUTF8toUTF16(function(){if(0===d)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);d=this.view.getUint8(a++);return 0===d?null:d}.bind(this),e=s(),!0);return b?(this.offset=a,e()):
{string:e(),length:a-c}};d.writeIString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var e=b,d;d=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];b+=4+d;var f=this.buffer.byteLength;b>f&&this.resize((f*=
2)>b?f:b);b-=4+d;this.view.setUint32(b,d,this.littleEndian);b+=4;n.encodeUTF16toUTF8(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));if(b!==e+4+d)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+4+d));return c?(this.offset=b,this):b-e};d.readIString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
a+" (+4) <= "+this.buffer.byteLength);}var c=a,e=this.readUint32(a),e=this.readUTF8String(e,f.METRICS_BYTES,a+=4);a+=e.length;return b?(this.offset=a,e.string):{string:e.string,length:a-c}};f.METRICS_CHARS="c";f.METRICS_BYTES="b";d.writeUTF8String=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+0) <= "+this.buffer.byteLength);}var e,d=b;e=n.calculateUTF16asUTF8(m(a))[1];b+=e;var f=this.buffer.byteLength;b>f&&this.resize((f*=2)>b?f:b);b-=e;n.encodeUTF16toUTF8(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));return c?(this.offset=b,this):b-d};d.writeString=d.writeUTF8String;f.calculateUTF8Chars=function(a){return n.calculateUTF16asUTF8(m(a))[0]};f.calculateUTF8Bytes=function(a){return n.calculateUTF16asUTF8(m(a))[1]};f.calculateString=f.calculateUTF8Bytes;d.readUTF8String=function(a,
b,c){"number"===typeof b&&(c=b,b=void 0);var e="undefined"===typeof c;e&&(c=this.offset);"undefined"===typeof b&&(b=f.METRICS_CHARS);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}var d=0,l=c,g;if(b===f.METRICS_CHARS){g=s();
n.decodeUTF8(function(){return d<a&&c<this.limit?this.view.getUint8(c++):null}.bind(this),function(a){++d;n.UTF8toUTF16(a,g)});if(d!==a)throw RangeError("Illegal range: Truncated data, "+d+" == "+a);return e?(this.offset=c,g()):{string:g(),length:c-l}}if(b===f.METRICS_BYTES){if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+"+a+") <= "+this.buffer.byteLength);
}var p=c+a;n.decodeUTF8toUTF16(function(){return c<p?this.view.getUint8(c++):null}.bind(this),g=s(),this.noAssert);if(c!==p)throw RangeError("Illegal range: Truncated data, "+c+" == "+p);return e?(this.offset=c,g()):{string:g(),length:c-l}}throw TypeError("Unsupported metrics: "+b);};d.readString=d.readUTF8String;d.writeVString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||
0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var e=b,d,l;d=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];l=f.calculateVarint32(d);b+=l+d;var g=this.buffer.byteLength;b>g&&this.resize((g*=2)>b?g:b);b-=l+d;b+=this.writeVarint32(d,b);n.encodeUTF16toUTF8(m(a),function(a){this.view.setUint8(b++,a)}.bind(this));if(b!==e+d+l)throw RangeError("Illegal range: Truncated data, "+
b+" == "+(b+d+l));return c?(this.offset=b,this):b-e};d.readVString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,e=this.readVarint32(a),e=this.readUTF8String(e.value,f.METRICS_BYTES,a+=e.length);a+=e.length;return b?(this.offset=a,e.string):{string:e.string,
length:a-c}};d.append=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var e="undefined"===typeof c;e&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof f||(a=f.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;c+=b;var d=this.buffer.byteLength;c>d&&this.resize((d*=2)>
c?d:c);(new Uint8Array(this.buffer,c-b)).set((new Uint8Array(a.buffer)).subarray(a.offset,a.limit));a.offset+=b;e&&(this.offset+=b);return this};d.appendTo=function(a,b){a.append(this,b);return this};d.assert=function(a){this.noAssert=!a;return this};d.capacity=function(){return this.buffer.byteLength};d.clear=function(){this.offset=0;this.limit=this.buffer.byteLength;this.markedOffset=-1;return this};d.clone=function(a){var b=new f(0,this.littleEndian,this.noAssert);a?(b.buffer=new ArrayBuffer(this.buffer.byteLength),
(new Uint8Array(b.buffer)).set(this.buffer),b.view=new DataView(b.buffer)):(b.buffer=this.buffer,b.view=this.view);b.offset=this.offset;b.markedOffset=this.markedOffset;b.limit=this.limit;return b};d.compact=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||
a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(0===a&&b===this.buffer.byteLength)return this;var c=b-a;if(0===c)return this.buffer=t,this.view=null,0<=this.markedOffset&&(this.markedOffset-=a),this.limit=this.offset=0,this;var e=new ArrayBuffer(c);(new Uint8Array(e)).set((new Uint8Array(this.buffer)).subarray(a,b));this.buffer=e;this.view=new DataView(e);0<=this.markedOffset&&(this.markedOffset-=a);this.offset=0;this.limit=c;return this};
d.copy=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return new f(0,this.littleEndian,this.noAssert);var c=b-a,e=new f(c,this.littleEndian,
this.noAssert);e.offset=0;e.limit=c;0<=e.markedOffset&&(e.markedOffset-=a);this.copyTo(e,0,a,b);return e};d.copyTo=function(a,b,c,e){var d,l;if(!this.noAssert&&!f.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");b=(l="undefined"===typeof b)?a.offset:b|0;c=(d="undefined"===typeof c)?this.offset:c|0;e="undefined"===typeof e?this.limit:e|0;if(0>b||b>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+b+" <= "+a.buffer.byteLength);if(0>c||e>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+
c+" <= "+this.buffer.byteLength);var g=e-c;if(0===g)return a;a.ensureCapacity(b+g);(new Uint8Array(a.buffer)).set((new Uint8Array(this.buffer)).subarray(c,e),b);d&&(this.offset+=g);l&&(a.offset+=g);return this};d.ensureCapacity=function(a){var b=this.buffer.byteLength;return b<a?this.resize((b*=2)>a?b:a):this};d.fill=function(a,b,c){var e="undefined"===typeof b;e&&(b=this.offset);"string"===typeof a&&0<a.length&&(a=a.charCodeAt(0));"undefined"===typeof b&&(b=this.offset);"undefined"===typeof c&&(c=
this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal begin: Not an integer");b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal end: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(b>=c)return this;for(;b<c;)this.view.setUint8(b++,a);e&&(this.offset=b);return this};
d.flip=function(){this.limit=this.offset;this.offset=0;return this};d.mark=function(a){a="undefined"===typeof a?this.offset:a;if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength);}this.markedOffset=a;return this};d.order=function(a){if(!this.noAssert&&"boolean"!==typeof a)throw TypeError("Illegal littleEndian: Not a boolean");
this.littleEndian=!!a;return this};d.LE=function(a){this.littleEndian="undefined"!==typeof a?!!a:!0;return this};d.BE=function(a){this.littleEndian="undefined"!==typeof a?!a:!1;return this};d.prepend=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var e="undefined"===typeof c;e&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
c+" (+0) <= "+this.buffer.byteLength);}a instanceof f||(a=f.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;var d=b-c;if(0<d){var l=new ArrayBuffer(this.buffer.byteLength+d),g=new Uint8Array(l);g.set((new Uint8Array(this.buffer)).subarray(c,this.buffer.byteLength),b);this.buffer=l;this.view=new DataView(l);this.offset+=d;0<=this.markedOffset&&(this.markedOffset+=d);this.limit+=d;c+=d}else g=new Uint8Array(this.buffer);g.set((new Uint8Array(a.buffer)).subarray(a.offset,a.limit),c-b);a.offset=a.limit;
e&&(this.offset-=b);return this};d.prependTo=function(a,b){a.prepend(this,b);return this};d.printDebug=function(a){"function"!==typeof a&&(a=console.log.bind(console));a(this.toString()+"\n-------------------------------------------------------------------\n"+this.toDebug(!0))};d.remaining=function(){return this.limit-this.offset};d.reset=function(){0<=this.markedOffset?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0;return this};d.resize=function(a){if(!this.noAssert){if("number"!==
typeof a||0!==a%1)throw TypeError("Illegal capacity: "+a+" (not an integer)");a|=0;if(0>a)throw RangeError("Illegal capacity: 0 <= "+a);}this.buffer.byteLength<a&&(a=new ArrayBuffer(a),(new Uint8Array(a)).set(new Uint8Array(this.buffer)),this.buffer=a,this.view=new DataView(a));return this};d.reverse=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return this;Array.prototype.reverse.call((new Uint8Array(this.buffer)).subarray(a,b));this.view=new DataView(this.buffer);return this};d.skip=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var b=this.offset+
a;if(!this.noAssert&&(0>b||b>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);this.offset=b;return this};d.slice=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+
a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this.clone();c.offset=a;c.limit=b;return c};d.toBuffer=function(a){var b=this.offset,c=this.limit;if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: Not an integer");b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal limit: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(!a&&0===b&&c===this.buffer.byteLength)return this.buffer;
if(b===c)return t;a=new ArrayBuffer(c-b);(new Uint8Array(a)).set((new Uint8Array(this.buffer)).subarray(b,c),0);return a};d.toArrayBuffer=d.toBuffer;d.toString=function(a,b,c){if("undefined"===typeof a)return"ByteBufferAB_DataView(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";"number"===typeof a&&(c=b=a="utf8");switch(a){case "utf8":return this.toUTF8(b,c);case "base64":return this.toBase64(b,c);case "hex":return this.toHex(b,c);case "binary":return this.toBinary(b,
c);case "debug":return this.toDebug();case "columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a);}};var v=function(){for(var a={},b=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],c=[],e=0,d=b.length;e<d;++e)c[b[e]]=e;a.encode=function(a,c){for(var e,d;null!==(e=a());)c(b[e>>2&63]),d=(e&3)<<4,null!==(e=
a())?(d|=e>>4&15,c(b[(d|e>>4&15)&63]),d=(e&15)<<2,null!==(e=a())?(c(b[(d|e>>6&3)&63]),c(b[e&63])):(c(b[d&63]),c(61))):(c(b[d&63]),c(61),c(61))};a.decode=function(a,b){function e(a){throw Error("Illegal character code: "+a);}for(var d,k,f;null!==(d=a());)if(k=c[d],"undefined"===typeof k&&e(d),null!==(d=a())&&(f=c[d],"undefined"===typeof f&&e(d),b(k<<2>>>0|(f&48)>>4),null!==(d=a()))){k=c[d];if("undefined"===typeof k)if(61===d)break;else e(d);b((f&15)<<4>>>0|(k&60)>>2);if(null!==(d=a())){f=c[d];if("undefined"===
typeof f)if(61===d)break;else e(d);b((k&3)<<6>>>0|f)}}};a.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)};return a}();d.toBase64=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);a|=0;b|=0;if(0>a||b>this.capacity||a>b)throw RangeError("begin, end");var c;v.encode(function(){return a<b?this.view.getUint8(a++):null}.bind(this),c=s());return c()};f.fromBase64=function(a,b){if("string"!==typeof a)throw TypeError("str");
var c=new f(a.length/4*3,b),e=0;v.decode(m(a),function(a){c.view.setUint8(e++,a)});c.limit=e;return c};f.btoa=function(a){return f.fromBinary(a).toBase64()};f.atob=function(a){return f.fromBase64(a).toBinary()};d.toBinary=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);a|=0;b|=0;if(0>a||b>this.capacity()||a>b)throw RangeError("begin, end");if(a===b)return"";for(var c=[],e=[];a<b;)c.push(this.view.getUint8(a++)),1024<=c.length&&(e.push(String.fromCharCode.apply(String,
c)),c=[]);return e.join("")+String.fromCharCode.apply(String,c)};f.fromBinary=function(a,b){if("string"!==typeof a)throw TypeError("str");for(var c=0,e=a.length,d,l=new f(e,b);c<e;){d=a.charCodeAt(c);if(255<d)throw RangeError("illegal char code: "+d);l.view.setUint8(c++,d)}l.limit=e;return l};d.toDebug=function(a){for(var b=-1,c=this.buffer.byteLength,e,d="",f="",g="";b<c;){-1!==b&&(e=this.view.getUint8(b),d=16>e?d+("0"+e.toString(16).toUpperCase()):d+e.toString(16).toUpperCase(),a&&(f+=32<e&&127>
e?String.fromCharCode(e):"."));++b;if(a&&0<b&&0===b%16&&b!==c){for(;51>d.length;)d+=" ";g+=d+f+"\n";d=f=""}d=b===this.offset&&b===this.limit?d+(b===this.markedOffset?"!":"|"):b===this.offset?d+(b===this.markedOffset?"[":"<"):b===this.limit?d+(b===this.markedOffset?"]":">"):d+(b===this.markedOffset?"'":a||0!==b&&b!==c?" ":"")}if(a&&" "!==d){for(;51>d.length;)d+=" ";g+=d+f+"\n"}return a?g:d};f.fromDebug=function(a,b,c){var e=a.length;b=new f((e+1)/3|0,b,c);for(var d=0,l=0,g,h=!1,m=!1,n=!1,r=!1,q=!1;d<
e;){switch(g=a.charAt(d++)){case "!":if(!c){if(m||n||r){q=!0;break}m=n=r=!0}b.offset=b.markedOffset=b.limit=l;h=!1;break;case "|":if(!c){if(m||r){q=!0;break}m=r=!0}b.offset=b.limit=l;h=!1;break;case "[":if(!c){if(m||n){q=!0;break}m=n=!0}b.offset=b.markedOffset=l;h=!1;break;case "<":if(!c){if(m){q=!0;break}m=!0}b.offset=l;h=!1;break;case "]":if(!c){if(r||n){q=!0;break}r=n=!0}b.limit=b.markedOffset=l;h=!1;break;case ">":if(!c){if(r){q=!0;break}r=!0}b.limit=l;h=!1;break;case "'":if(!c){if(n){q=!0;break}n=
!0}b.markedOffset=l;h=!1;break;case " ":h=!1;break;default:if(!c&&h){q=!0;break}g=parseInt(g+a.charAt(d++),16);if(!c&&(isNaN(g)||0>g||255<g))throw TypeError("Illegal str: Not a debug encoded string");b.view.setUint8(l++,g);h=!0}if(q)throw TypeError("Illegal str: Invalid symbol at "+d);}if(!c){if(!m||!r)throw TypeError("Illegal str: Missing offset or limit");if(l<b.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+l+" < "+e);}return b};d.toHex=function(a,b){a=
"undefined"===typeof a?this.offset:a;b="undefined"===typeof b?this.limit:b;if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}for(var c=Array(b-a),e;a<b;)e=this.view.getUint8(a++),16>e?c.push("0",e.toString(16)):c.push(e.toString(16));return c.join("")};
f.fromHex=function(a,b,c){if(!c){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if(0!==a.length%2)throw TypeError("Illegal str: Length not a multiple of 2");}var e=a.length;b=new f(e/2|0,b);for(var d,h=0,g=0;h<e;h+=2){d=parseInt(a.substring(h,h+2),16);if(!c&&(!isFinite(d)||0>d||255<d))throw TypeError("Illegal str: Contains non-hex characters");b.view.setUint8(g++,d)}b.limit=g;return b};var n=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(a,c){var e=null;"number"===
typeof a&&(e=a,a=function(){return null});for(;null!==e||null!==(e=a());)128>e?c(e&127):(2048>e?c(e>>6&31|192):(65536>e?c(e>>12&15|224):(c(e>>18&7|240),c(e>>12&63|128)),c(e>>6&63|128)),c(e&63|128)),e=null},decodeUTF8:function(a,c){for(var e,d,f,g,h=function(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;};null!==(e=a());)if(0===(e&128))c(e);else if(192===(e&224))null===(d=a())&&h([e,d]),c((e&31)<<6|d&63);else if(224===(e&240))null!==(d=a())&&null!==
(f=a())||h([e,d,f]),c((e&15)<<12|(d&63)<<6|f&63);else if(240===(e&248))null!==(d=a())&&null!==(f=a())&&null!==(g=a())||h([e,d,f,g]),c((e&7)<<18|(d&63)<<12|(f&63)<<6|g&63);else throw RangeError("Illegal starting byte: "+e);},UTF16toUTF8:function(a,c){for(var e,d=null;null!==(e=null!==d?d:a());)55296<=e&&57343>=e&&null!==(d=a())&&56320<=d&&57343>=d?(c(1024*(e-55296)+d-56320+65536),d=null):c(e);null!==d&&c(d)},UTF8toUTF16:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});
for(;null!==d||null!==(d=a());)65535>=d?c(d):(d-=65536,c((d>>10)+55296),c(d%1024+56320)),d=null},encodeUTF16toUTF8:function(b,c){a.UTF16toUTF8(b,function(b){a.encodeUTF8(b,c)})},decodeUTF8toUTF16:function(b,c){a.decodeUTF8(b,function(b){a.UTF8toUTF16(b,c)})},calculateCodePoint:function(a){return 128>a?1:2048>a?2:65536>a?3:4},calculateUTF8:function(a){for(var c,d=0;null!==(c=a());)d+=128>c?1:2048>c?2:65536>c?3:4;return d},calculateUTF16asUTF8:function(b){var c=0,d=0;a.UTF16toUTF8(b,function(a){++c;
d+=128>a?1:2048>a?2:65536>a?3:4});return[c,d]}};return a}();d.toUTF8=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c;try{n.decodeUTF8toUTF16(function(){return a<
b?this.view.getUint8(a++):null}.bind(this),c=s())}catch(d){if(a!==b)throw RangeError("Illegal range: Truncated data, "+a+" != "+b);}return c()};f.fromUTF8=function(a,b,c){if(!c&&"string"!==typeof a)throw TypeError("Illegal str: Not a string");var d=new f(n.calculateUTF16asUTF8(m(a),!0)[1],b,c),h=0;n.encodeUTF16toUTF8(m(a),function(a){d.view.setUint8(h++,a)});d.limit=h;return d};return f});

Binary file not shown.

File diff suppressed because one or more lines are too long

3454
node_modules/bytebuffer/dist/bytebuffer-node.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

3746
node_modules/bytebuffer/dist/bytebuffer.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

93
node_modules/bytebuffer/dist/bytebuffer.min.js generated vendored Normal file
View File

@ -0,0 +1,93 @@
/*
bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
Backing buffer: ArrayBuffer, Accessor: Uint8Array
Released under the Apache License, Version 2.0
see: https://github.com/dcodeIO/bytebuffer.js for details
*/
(function(k,m){if("function"===typeof define&&define.amd)define(["long"],m);else if("function"===typeof require&&"object"===typeof module&&module&&module.exports){var r=module,s;try{s=require("long")}catch(u){}s=m(s);r.exports=s}else(k.dcodeIO=k.dcodeIO||{}).ByteBuffer=m(k.dcodeIO.Long)})(this,function(k){function m(a){var b=0;return function(){return b<a.length?a.charCodeAt(b++):null}}function r(){var a=[],b=[];return function(){if(0===arguments.length)return b.join("")+w.apply(String,a);1024<a.length+
arguments.length&&(b.push(w.apply(String,a)),a.length=0);Array.prototype.push.apply(a,arguments)}}function s(a,b,c,d,f){var l;l=8*f-d-1;var g=(1<<l)-1,e=g>>1,h=-7;f=c?f-1:0;var k=c?-1:1,p=a[b+f];f+=k;c=p&(1<<-h)-1;p>>=-h;for(h+=l;0<h;c=256*c+a[b+f],f+=k,h-=8);l=c&(1<<-h)-1;c>>=-h;for(h+=d;0<h;l=256*l+a[b+f],f+=k,h-=8);if(0===c)c=1-e;else{if(c===g)return l?NaN:Infinity*(p?-1:1);l+=Math.pow(2,d);c-=e}return(p?-1:1)*l*Math.pow(2,c-d)}function u(a,b,c,d,f,l){var g,e=8*l-f-1,h=(1<<e)-1,k=h>>1,p=23===f?
Math.pow(2,-24)-Math.pow(2,-77):0;l=d?0:l-1;var m=d?1:-1,n=0>b||0===b&&0>1/b?1:0;b=Math.abs(b);isNaN(b)||Infinity===b?(b=isNaN(b)?1:0,d=h):(d=Math.floor(Math.log(b)/Math.LN2),1>b*(g=Math.pow(2,-d))&&(d--,g*=2),b=1<=d+k?b+p/g:b+p*Math.pow(2,1-k),2<=b*g&&(d++,g/=2),d+k>=h?(b=0,d=h):1<=d+k?(b=(b*g-1)*Math.pow(2,f),d+=k):(b=b*Math.pow(2,k-1)*Math.pow(2,f),d=0));for(;8<=f;a[c+l]=b&255,l+=m,b/=256,f-=8);d=d<<f|b;for(e+=f;0<e;a[c+l]=d&255,l+=m,d/=256,e-=8);a[c+l-m]|=128*n}var h=function(a,b,c){"undefined"===
typeof a&&(a=h.DEFAULT_CAPACITY);"undefined"===typeof b&&(b=h.DEFAULT_ENDIAN);"undefined"===typeof c&&(c=h.DEFAULT_NOASSERT);if(!c){a|=0;if(0>a)throw RangeError("Illegal capacity");b=!!b;c=!!c}this.buffer=0===a?v:new ArrayBuffer(a);this.view=0===a?null:new Uint8Array(this.buffer);this.offset=0;this.markedOffset=-1;this.limit=a;this.littleEndian=b;this.noAssert=c};h.VERSION="5.0.1";h.LITTLE_ENDIAN=!0;h.BIG_ENDIAN=!1;h.DEFAULT_CAPACITY=16;h.DEFAULT_ENDIAN=h.BIG_ENDIAN;h.DEFAULT_NOASSERT=!1;h.Long=k||
null;var e=h.prototype;Object.defineProperty(e,"__isByteBuffer__",{value:!0,enumerable:!1,configurable:!1});var v=new ArrayBuffer(0),w=String.fromCharCode;h.accessor=function(){return Uint8Array};h.allocate=function(a,b,c){return new h(a,b,c)};h.concat=function(a,b,c,d){if("boolean"===typeof b||"string"!==typeof b)d=c,c=b,b=void 0;for(var f=0,l=0,g=a.length,e;l<g;++l)h.isByteBuffer(a[l])||(a[l]=h.wrap(a[l],b)),e=a[l].limit-a[l].offset,0<e&&(f+=e);if(0===f)return new h(0,c,d);b=new h(f,c,d);for(l=
0;l<g;)c=a[l++],e=c.limit-c.offset,0>=e||(b.view.set(c.view.subarray(c.offset,c.limit),b.offset),b.offset+=e);b.limit=b.offset;b.offset=0;return b};h.isByteBuffer=function(a){return!0===(a&&a.__isByteBuffer__)};h.type=function(){return ArrayBuffer};h.wrap=function(a,b,c,d){"string"!==typeof b&&(d=c,c=b,b=void 0);if("string"===typeof a)switch("undefined"===typeof b&&(b="utf8"),b){case "base64":return h.fromBase64(a,c);case "hex":return h.fromHex(a,c);case "binary":return h.fromBinary(a,c);case "utf8":return h.fromUTF8(a,
c);case "debug":return h.fromDebug(a,c);default:throw Error("Unsupported encoding: "+b);}if(null===a||"object"!==typeof a)throw TypeError("Illegal buffer");if(h.isByteBuffer(a))return b=e.clone.call(a),b.markedOffset=-1,b;if(a instanceof Uint8Array)b=new h(0,c,d),0<a.length&&(b.buffer=a.buffer,b.offset=a.byteOffset,b.limit=a.byteOffset+a.byteLength,b.view=new Uint8Array(a.buffer));else if(a instanceof ArrayBuffer)b=new h(0,c,d),0<a.byteLength&&(b.buffer=a,b.offset=0,b.limit=a.byteLength,b.view=0<
a.byteLength?new Uint8Array(a):null);else if("[object Array]"===Object.prototype.toString.call(a))for(b=new h(a.length,c,d),b.limit=a.length,c=0;c<a.length;++c)b.view[c]=a[c];else throw TypeError("Illegal buffer");return b};e.writeBitSet=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if(!(a instanceof Array))throw TypeError("Illegal BitSet: Not an array");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>
this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f=a.length,e=f>>3,g=0,h;for(b+=this.writeVarint32(f,b);e--;)h=!!a[g++]&1|(!!a[g++]&1)<<1|(!!a[g++]&1)<<2|(!!a[g++]&1)<<3|(!!a[g++]&1)<<4|(!!a[g++]&1)<<5|(!!a[g++]&1)<<6|(!!a[g++]&1)<<7,this.writeByte(h,b++);if(g<f){for(h=e=0;g<f;)h|=(!!a[g++]&1)<<e++;this.writeByte(h,b++)}return c?(this.offset=b,this):b-d};e.readBitSet=function(a){var b="undefined"===typeof a;b&&(a=this.offset);var c=this.readVarint32(a),
d=c.value,f=d>>3,e=0,g=[];for(a+=c.length;f--;)c=this.readByte(a++),g[e++]=!!(c&1),g[e++]=!!(c&2),g[e++]=!!(c&4),g[e++]=!!(c&8),g[e++]=!!(c&16),g[e++]=!!(c&32),g[e++]=!!(c&64),g[e++]=!!(c&128);if(e<d)for(f=0,c=this.readByte(a++);e<d;)g[e++]=!!(c>>f++&1);b&&(this.offset=a);return g};e.readBytes=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+"+a+") <= "+this.buffer.byteLength);}var d=this.slice(b,b+a);c&&(this.offset+=a);return d};e.writeBytes=e.append;e.writeInt8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);
}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);this.view[b-1]=a;c&&(this.offset+=1);return this};e.writeByte=e.writeInt8;e.readInt8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view[a];128===(a&128)&&(a=-(255-a+1));b&&(this.offset+=
1);return a};e.readByte=e.readInt8;e.writeUint8=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=1;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);
this.view[b-1]=a;c&&(this.offset+=1);return this};e.writeUInt8=e.writeUint8;e.readUint8=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}a=this.view[a];b&&(this.offset+=1);return a};e.readUInt8=e.readUint8;e.writeInt16=function(a,b){var c="undefined"===typeof b;
c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=2;this.littleEndian?(this.view[b+1]=(a&65280)>>>8,this.view[b]=a&255):(this.view[b]=(a&65280)>>>
8,this.view[b+1]=a&255);c&&(this.offset+=2);return this};e.writeShort=e.writeInt16;e.readInt16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]);32768===(c&32768)&&
(c=-(65535-c+1));b&&(this.offset+=2);return c};e.readShort=e.readInt16;e.writeUint16=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=2;var d=this.buffer.byteLength;
b>d&&this.resize((d*=2)>b?d:b);b-=2;this.littleEndian?(this.view[b+1]=(a&65280)>>>8,this.view[b]=a&255):(this.view[b]=(a&65280)>>>8,this.view[b+1]=a&255);c&&(this.offset+=2);return this};e.writeUInt16=e.writeUint16;e.readUint16=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+2>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+2) <= "+this.buffer.byteLength);
}var c=0;this.littleEndian?(c=this.view[a],c|=this.view[a+1]<<8):(c=this.view[a]<<8,c|=this.view[a+1]);b&&(this.offset+=2);return c};e.readUInt16=e.readUint16;e.writeInt32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=4;this.littleEndian?(this.view[b+3]=a>>>24&255,this.view[b+2]=a>>>16&255,this.view[b+1]=a>>>8&255,this.view[b]=a&255):(this.view[b]=a>>>24&255,this.view[b+1]=a>>>16&255,this.view[b+2]=a>>>8&255,this.view[b+3]=a&255);c&&(this.offset+=4);return this};e.writeInt=e.writeInt32;e.readInt32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%
1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);b&&(this.offset+=4);return c|0};e.readInt=e.readInt32;e.writeUint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);
if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=4;this.littleEndian?(this.view[b+3]=a>>>24&255,this.view[b+2]=a>>>16&255,this.view[b+1]=a>>>8&255,this.view[b]=
a&255):(this.view[b]=a>>>24&255,this.view[b+1]=a>>>16&255,this.view[b+2]=a>>>8&255,this.view[b+3]=a&255);c&&(this.offset+=4);return this};e.writeUInt32=e.writeUint32;e.readUint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=0;this.littleEndian?(c=this.view[a+
2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0):(c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);b&&(this.offset+=4);return c};e.readUInt32=e.readUint32;k&&(e.writeInt64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==
typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;var d=a.low,f=a.high;this.littleEndian?(this.view[b+3]=d>>>24&255,this.view[b+2]=d>>>16&255,this.view[b+1]=d>>>8&255,this.view[b]=d&255,b+=4,this.view[b+3]=
f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255,this.view[b+3]=f&255,b+=4,this.view[b]=d>>>24&255,this.view[b+1]=d>>>16&255,this.view[b+2]=d>>>8&255,this.view[b+3]=d&255);c&&(this.offset+=8);return this},e.writeLong=e.writeInt64,e.readInt64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");
a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}var c=0,d=0;this.littleEndian?(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,d=this.view[a+2]<<16,d|=this.view[a+1]<<8,d|=this.view[a],d+=this.view[a+3]<<24>>>0):(d=this.view[a+1]<<16,d|=this.view[a+2]<<8,d|=this.view[a+3],d+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);
a=new k(c,d,!1);b&&(this.offset+=8);return a},e.readLong=e.readInt64,e.writeUint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=8;var d=a.low,f=a.high;this.littleEndian?(this.view[b+3]=d>>>24&255,this.view[b+2]=d>>>16&255,this.view[b+1]=d>>>8&255,this.view[b]=d&255,b+=4,this.view[b+3]=f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255,
this.view[b+3]=f&255,b+=4,this.view[b]=d>>>24&255,this.view[b+1]=d>>>16&255,this.view[b+2]=d>>>8&255,this.view[b+3]=d&255);c&&(this.offset+=8);return this},e.writeUInt64=e.writeUint64,e.readUint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}var c=0,d=0;this.littleEndian?
(c=this.view[a+2]<<16,c|=this.view[a+1]<<8,c|=this.view[a],c+=this.view[a+3]<<24>>>0,a+=4,d=this.view[a+2]<<16,d|=this.view[a+1]<<8,d|=this.view[a],d+=this.view[a+3]<<24>>>0):(d=this.view[a+1]<<16,d|=this.view[a+2]<<8,d|=this.view[a+3],d+=this.view[a]<<24>>>0,a+=4,c=this.view[a+1]<<16,c|=this.view[a+2]<<8,c|=this.view[a+3],c+=this.view[a]<<24>>>0);a=new k(c,d,!0);b&&(this.offset+=8);return a},e.readUInt64=e.readUint64);e.writeFloat32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==
typeof a)throw TypeError("Illegal value: "+a+" (not a number)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=4;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);u(this.view,a,b-4,this.littleEndian,23,4);c&&(this.offset+=4);return this};e.writeFloat=e.writeFloat32;e.readFloat32=function(a){var b="undefined"===typeof a;b&&
(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}a=s(this.view,a,this.littleEndian,23,4);b&&(this.offset+=4);return a};e.readFloat=e.readFloat32;e.writeFloat64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a)throw TypeError("Illegal value: "+a+" (not a number)");
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}b+=8;var d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);u(this.view,a,b-8,this.littleEndian,52,8);c&&(this.offset+=8);return this};e.writeDouble=e.writeFloat64;e.readFloat64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==
a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+8>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+8) <= "+this.buffer.byteLength);}a=s(this.view,a,this.littleEndian,52,8);b&&(this.offset+=8);return a};e.readDouble=e.readFloat64;h.MAX_VARINT32_BYTES=5;h.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};h.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};h.zigZagDecode32=function(a){return a>>>1^-(a&
1)|0};e.writeVarint32=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=h.calculateVarint32(a),f;b+=d;f=this.buffer.byteLength;b>f&&this.resize((f*=2)>b?f:b);
b-=d;for(a>>>=0;128<=a;)f=a&127|128,this.view[b++]=f,a>>>=7;this.view[b++]=a;return c?(this.offset=b,this):d};e.writeVarint32ZigZag=function(a,b){return this.writeVarint32(h.zigZagEncode32(a),b)};e.readVarint32=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);
}var c=0,d=0,f;do{if(!this.noAssert&&a>this.limit)throw a=Error("Truncated"),a.truncated=!0,a;f=this.view[a++];5>c&&(d|=(f&127)<<7*c);++c}while(0!==(f&128));d|=0;return b?(this.offset=a,d):{value:d,length:c}};e.readVarint32ZigZag=function(a){a=this.readVarint32(a);"object"===typeof a?a.value=h.zigZagDecode32(a.value):a=h.zigZagDecode32(a);return a};k&&(h.MAX_VARINT64_BYTES=10,h.calculateVarint64=function(a){"number"===typeof a?a=k.fromNumber(a):"string"===typeof a&&(a=k.fromString(a));var b=a.toInt()>>>
0,c=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==c?16384>b?128>b?1:2:2097152>b?3:4:16384>c?128>c?5:6:2097152>c?7:8:128>a?9:10},h.zigZagEncode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()},h.zigZagDecode64=function(a){"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&&
(a=a.toSigned());return a.shiftRightUnsigned(1).xor(a.and(k.ONE).toSigned().negate()).toSigned()},e.writeVarint64=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"===typeof a)a=k.fromNumber(a);else if("string"===typeof a)a=k.fromString(a);else if(!(a&&a instanceof k))throw TypeError("Illegal value: "+a+" (not an integer or Long)");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
b+" (+0) <= "+this.buffer.byteLength);}"number"===typeof a?a=k.fromNumber(a,!1):"string"===typeof a?a=k.fromString(a,!1):!1!==a.unsigned&&(a=a.toSigned());var d=h.calculateVarint64(a),f=a.toInt()>>>0,e=a.shiftRightUnsigned(28).toInt()>>>0,g=a.shiftRightUnsigned(56).toInt()>>>0;b+=d;var t=this.buffer.byteLength;b>t&&this.resize((t*=2)>b?t:b);b-=d;switch(d){case 10:this.view[b+9]=g>>>7&1;case 9:this.view[b+8]=9!==d?g|128:g&127;case 8:this.view[b+7]=8!==d?e>>>21|128:e>>>21&127;case 7:this.view[b+6]=
7!==d?e>>>14|128:e>>>14&127;case 6:this.view[b+5]=6!==d?e>>>7|128:e>>>7&127;case 5:this.view[b+4]=5!==d?e|128:e&127;case 4:this.view[b+3]=4!==d?f>>>21|128:f>>>21&127;case 3:this.view[b+2]=3!==d?f>>>14|128:f>>>14&127;case 2:this.view[b+1]=2!==d?f>>>7|128:f>>>7&127;case 1:this.view[b]=1!==d?f|128:f&127}return c?(this.offset+=d,this):d},e.writeVarint64ZigZag=function(a,b){return this.writeVarint64(h.zigZagEncode64(a),b)},e.readVarint64=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==
typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=0,f=0,e=0,g=0,g=this.view[a++],d=g&127;if(g&128&&(g=this.view[a++],d|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],d|=(g&127)<<14,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],d|=(g&127)<<21,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],
f=g&127,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<14,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],f|=(g&127)<<21,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],e=g&127,g&128||this.noAssert&&"undefined"===typeof g)&&(g=this.view[a++],e|=(g&127)<<7,g&128||this.noAssert&&"undefined"===typeof g))throw Error("Buffer overrun");d=k.fromBits(d|f<<28,f>>>4|
e<<24,!1);return b?(this.offset=a,d):{value:d,length:a-c}},e.readVarint64ZigZag=function(a){(a=this.readVarint64(a))&&a.value instanceof k?a.value=h.zigZagDecode64(a.value):a=h.zigZagDecode64(a);return a});e.writeCString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);var d,f=a.length;if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");for(d=0;d<f;++d)if(0===a.charCodeAt(d))throw RangeError("Illegal str: Contains NULL-characters");if("number"!==typeof b||
0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}f=n.calculateUTF16asUTF8(m(a))[1];b+=f+1;d=this.buffer.byteLength;b>d&&this.resize((d*=2)>b?d:b);b-=f+1;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));this.view[b++]=0;return c?(this.offset=b,this):f};e.readCString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==
typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d,f=-1;n.decodeUTF8toUTF16(function(){if(0===f)return null;if(a>=this.limit)throw RangeError("Illegal range: Truncated data, "+a+" < "+this.limit);f=this.view[a++];return 0===f?null:f}.bind(this),d=r(),!0);return b?(this.offset=a,d()):{string:d(),length:a-c}};e.writeIString=function(a,b){var c=
"undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f;f=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];b+=4+f;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=4+f;this.littleEndian?(this.view[b+
3]=f>>>24&255,this.view[b+2]=f>>>16&255,this.view[b+1]=f>>>8&255,this.view[b]=f&255):(this.view[b]=f>>>24&255,this.view[b+1]=f>>>16&255,this.view[b+2]=f>>>8&255,this.view[b+3]=f&255);b+=4;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));if(b!==d+4+f)throw RangeError("Illegal range: Truncated data, "+b+" == "+(b+4+f));return c?(this.offset=b,this):b-d};e.readIString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+
a+" (not an integer)");a>>>=0;if(0>a||a+4>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+4) <= "+this.buffer.byteLength);}var c=a,d=this.readUint32(a),d=this.readUTF8String(d,h.METRICS_BYTES,a+=4);a+=d.length;return b?(this.offset=a,d.string):{string:d.string,length:a-c}};h.METRICS_CHARS="c";h.METRICS_BYTES="b";e.writeUTF8String=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+
b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d,f=b;d=n.calculateUTF16asUTF8(m(a))[1];b+=d;var e=this.buffer.byteLength;b>e&&this.resize((e*=2)>b?e:b);b-=d;n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));return c?(this.offset=b,this):b-f};e.writeString=e.writeUTF8String;h.calculateUTF8Chars=function(a){return n.calculateUTF16asUTF8(m(a))[0]};h.calculateUTF8Bytes=function(a){return n.calculateUTF16asUTF8(m(a))[1]};
h.calculateString=h.calculateUTF8Bytes;e.readUTF8String=function(a,b,c){"number"===typeof b&&(c=b,b=void 0);var d="undefined"===typeof c;d&&(c=this.offset);"undefined"===typeof b&&(b=h.METRICS_CHARS);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+
this.buffer.byteLength);}var f=0,e=c,g;if(b===h.METRICS_CHARS){g=r();n.decodeUTF8(function(){return f<a&&c<this.limit?this.view[c++]:null}.bind(this),function(a){++f;n.UTF8toUTF16(a,g)});if(f!==a)throw RangeError("Illegal range: Truncated data, "+f+" == "+a);return d?(this.offset=c,g()):{string:g(),length:c-e}}if(b===h.METRICS_BYTES){if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+a>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+
c+" (+"+a+") <= "+this.buffer.byteLength);}var k=c+a;n.decodeUTF8toUTF16(function(){return c<k?this.view[c++]:null}.bind(this),g=r(),this.noAssert);if(c!==k)throw RangeError("Illegal range: Truncated data, "+c+" == "+k);return d?(this.offset=c,g()):{string:g(),length:c-e}}throw TypeError("Unsupported metrics: "+b);};e.readString=e.readUTF8String;e.writeVString=function(a,b){var c="undefined"===typeof b;c&&(b=this.offset);if(!this.noAssert){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");
if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: "+b+" (not an integer)");b>>>=0;if(0>b||b+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+b+" (+0) <= "+this.buffer.byteLength);}var d=b,f,e;f=n.calculateUTF16asUTF8(m(a),this.noAssert)[1];e=h.calculateVarint32(f);b+=e+f;var g=this.buffer.byteLength;b>g&&this.resize((g*=2)>b?g:b);b-=e+f;b+=this.writeVarint32(f,b);n.encodeUTF16toUTF8(m(a),function(a){this.view[b++]=a}.bind(this));if(b!==d+f+e)throw RangeError("Illegal range: Truncated data, "+
b+" == "+(b+f+e));return c?(this.offset=b,this):b-d};e.readVString=function(a){var b="undefined"===typeof a;b&&(a=this.offset);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+1>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+1) <= "+this.buffer.byteLength);}var c=a,d=this.readVarint32(a),d=this.readUTF8String(d.value,h.METRICS_BYTES,a+=d.length);a+=d.length;return b?(this.offset=a,d.string):{string:d.string,
length:a-c}};e.append=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof h||(a=h.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;c+=b;var f=this.buffer.byteLength;c>f&&this.resize((f*=2)>
c?f:c);c-=b;this.view.set(a.view.subarray(a.offset,a.limit),c);a.offset+=b;d&&(this.offset+=b);return this};e.appendTo=function(a,b){a.append(this,b);return this};e.assert=function(a){this.noAssert=!a;return this};e.capacity=function(){return this.buffer.byteLength};e.clear=function(){this.offset=0;this.limit=this.buffer.byteLength;this.markedOffset=-1;return this};e.clone=function(a){var b=new h(0,this.littleEndian,this.noAssert);a?(b.buffer=new ArrayBuffer(this.buffer.byteLength),b.view=new Uint8Array(b.buffer)):
(b.buffer=this.buffer,b.view=this.view);b.offset=this.offset;b.markedOffset=this.markedOffset;b.limit=this.limit;return b};e.compact=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+
b+" <= "+this.buffer.byteLength);}if(0===a&&b===this.buffer.byteLength)return this;var c=b-a;if(0===c)return this.buffer=v,this.view=null,0<=this.markedOffset&&(this.markedOffset-=a),this.limit=this.offset=0,this;var d=new ArrayBuffer(c),f=new Uint8Array(d);f.set(this.view.subarray(a,b));this.buffer=d;this.view=f;0<=this.markedOffset&&(this.markedOffset-=a);this.offset=0;this.limit=c;return this};e.copy=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==
typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return new h(0,this.littleEndian,this.noAssert);var c=b-a,d=new h(c,this.littleEndian,this.noAssert);d.offset=0;d.limit=c;0<=d.markedOffset&&(d.markedOffset-=a);this.copyTo(d,0,a,b);return d};e.copyTo=function(a,
b,c,d){var f,e;if(!this.noAssert&&!h.isByteBuffer(a))throw TypeError("Illegal target: Not a ByteBuffer");b=(e="undefined"===typeof b)?a.offset:b|0;c=(f="undefined"===typeof c)?this.offset:c|0;d="undefined"===typeof d?this.limit:d|0;if(0>b||b>a.buffer.byteLength)throw RangeError("Illegal target range: 0 <= "+b+" <= "+a.buffer.byteLength);if(0>c||d>this.buffer.byteLength)throw RangeError("Illegal source range: 0 <= "+c+" <= "+this.buffer.byteLength);var g=d-c;if(0===g)return a;a.ensureCapacity(b+g);
a.view.set(this.view.subarray(c,d),b);f&&(this.offset+=g);e&&(a.offset+=g);return this};e.ensureCapacity=function(a){var b=this.buffer.byteLength;return b<a?this.resize((b*=2)>a?b:a):this};e.fill=function(a,b,c){var d="undefined"===typeof b;d&&(b=this.offset);"string"===typeof a&&0<a.length&&(a=a.charCodeAt(0));"undefined"===typeof b&&(b=this.offset);"undefined"===typeof c&&(c=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal value: "+a+" (not an integer)");a|=
0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal begin: Not an integer");b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal end: Not an integer");c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(b>=c)return this;for(;b<c;)this.view[b++]=a;d&&(this.offset=b);return this};e.flip=function(){this.limit=this.offset;this.offset=0;return this};e.mark=function(a){a="undefined"===typeof a?this.offset:a;
if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal offset: "+a+" (not an integer)");a>>>=0;if(0>a||a+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+a+" (+0) <= "+this.buffer.byteLength);}this.markedOffset=a;return this};e.order=function(a){if(!this.noAssert&&"boolean"!==typeof a)throw TypeError("Illegal littleEndian: Not a boolean");this.littleEndian=!!a;return this};e.LE=function(a){this.littleEndian="undefined"!==typeof a?!!a:!0;return this};e.BE=function(a){this.littleEndian=
"undefined"!==typeof a?!a:!1;return this};e.prepend=function(a,b,c){if("number"===typeof b||"string"!==typeof b)c=b,b=void 0;var d="undefined"===typeof c;d&&(c=this.offset);if(!this.noAssert){if("number"!==typeof c||0!==c%1)throw TypeError("Illegal offset: "+c+" (not an integer)");c>>>=0;if(0>c||c+0>this.buffer.byteLength)throw RangeError("Illegal offset: 0 <= "+c+" (+0) <= "+this.buffer.byteLength);}a instanceof h||(a=h.wrap(a,b));b=a.limit-a.offset;if(0>=b)return this;var f=b-c;if(0<f){var e=new ArrayBuffer(this.buffer.byteLength+
f),g=new Uint8Array(e);g.set(this.view.subarray(c,this.buffer.byteLength),b);this.buffer=e;this.view=g;this.offset+=f;0<=this.markedOffset&&(this.markedOffset+=f);this.limit+=f;c+=f}else new Uint8Array(this.buffer);this.view.set(a.view.subarray(a.offset,a.limit),c-b);a.offset=a.limit;d&&(this.offset-=b);return this};e.prependTo=function(a,b){a.prepend(this,b);return this};e.printDebug=function(a){"function"!==typeof a&&(a=console.log.bind(console));a(this.toString()+"\n-------------------------------------------------------------------\n"+
this.toDebug(!0))};e.remaining=function(){return this.limit-this.offset};e.reset=function(){0<=this.markedOffset?(this.offset=this.markedOffset,this.markedOffset=-1):this.offset=0;return this};e.resize=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal capacity: "+a+" (not an integer)");a|=0;if(0>a)throw RangeError("Illegal capacity: 0 <= "+a);}if(this.buffer.byteLength<a){a=new ArrayBuffer(a);var b=new Uint8Array(a);b.set(this.view);this.buffer=a;this.view=b}return this};
e.reverse=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}if(a===b)return this;Array.prototype.reverse.call(this.view.subarray(a,b));return this};
e.skip=function(a){if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal length: "+a+" (not an integer)");a|=0}var b=this.offset+a;if(!this.noAssert&&(0>b||b>this.buffer.byteLength))throw RangeError("Illegal length: 0 <= "+this.offset+" + "+a+" <= "+this.buffer.byteLength);this.offset=b;return this};e.slice=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");
a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+this.buffer.byteLength);}var c=this.clone();c.offset=a;c.limit=b;return c};e.toBuffer=function(a){var b=this.offset,c=this.limit;if(!this.noAssert){if("number"!==typeof b||0!==b%1)throw TypeError("Illegal offset: Not an integer");b>>>=0;if("number"!==typeof c||0!==c%1)throw TypeError("Illegal limit: Not an integer");
c>>>=0;if(0>b||b>c||c>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+b+" <= "+c+" <= "+this.buffer.byteLength);}if(!a&&0===b&&c===this.buffer.byteLength)return this.buffer;if(b===c)return v;a=new ArrayBuffer(c-b);(new Uint8Array(a)).set((new Uint8Array(this.buffer)).subarray(b,c),0);return a};e.toArrayBuffer=e.toBuffer;e.toString=function(a,b,c){if("undefined"===typeof a)return"ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+
")";"number"===typeof a&&(c=b=a="utf8");switch(a){case "utf8":return this.toUTF8(b,c);case "base64":return this.toBase64(b,c);case "hex":return this.toHex(b,c);case "binary":return this.toBinary(b,c);case "debug":return this.toDebug();case "columns":return this.toColumns();default:throw Error("Unsupported encoding: "+a);}};var x=function(){for(var a={},b=[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,
114,115,116,117,118,119,120,121,122,48,49,50,51,52,53,54,55,56,57,43,47],c=[],d=0,f=b.length;d<f;++d)c[b[d]]=d;a.encode=function(a,c){for(var d,f;null!==(d=a());)c(b[d>>2&63]),f=(d&3)<<4,null!==(d=a())?(f|=d>>4&15,c(b[(f|d>>4&15)&63]),f=(d&15)<<2,null!==(d=a())?(c(b[(f|d>>6&3)&63]),c(b[d&63])):(c(b[f&63]),c(61))):(c(b[f&63]),c(61),c(61))};a.decode=function(a,b){function d(a){throw Error("Illegal character code: "+a);}for(var f,e,h;null!==(f=a());)if(e=c[f],"undefined"===typeof e&&d(f),null!==(f=a())&&
(h=c[f],"undefined"===typeof h&&d(f),b(e<<2>>>0|(h&48)>>4),null!==(f=a()))){e=c[f];if("undefined"===typeof e)if(61===f)break;else d(f);b((h&15)<<4>>>0|(e&60)>>2);if(null!==(f=a())){h=c[f];if("undefined"===typeof h)if(61===f)break;else d(f);b((e&3)<<6>>>0|h)}}};a.test=function(a){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(a)};return a}();e.toBase64=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);a|=0;b|=0;if(0>a||b>this.capacity||
a>b)throw RangeError("begin, end");var c;x.encode(function(){return a<b?this.view[a++]:null}.bind(this),c=r());return c()};h.fromBase64=function(a,b){if("string"!==typeof a)throw TypeError("str");var c=new h(a.length/4*3,b),d=0;x.decode(m(a),function(a){c.view[d++]=a});c.limit=d;return c};h.btoa=function(a){return h.fromBinary(a).toBase64()};h.atob=function(a){return h.fromBase64(a).toBinary()};e.toBinary=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);
a|=0;b|=0;if(0>a||b>this.capacity()||a>b)throw RangeError("begin, end");if(a===b)return"";for(var c=[],d=[];a<b;)c.push(this.view[a++]),1024<=c.length&&(d.push(String.fromCharCode.apply(String,c)),c=[]);return d.join("")+String.fromCharCode.apply(String,c)};h.fromBinary=function(a,b){if("string"!==typeof a)throw TypeError("str");for(var c=0,d=a.length,f,e=new h(d,b);c<d;){f=a.charCodeAt(c);if(255<f)throw RangeError("illegal char code: "+f);e.view[c++]=f}e.limit=d;return e};e.toDebug=function(a){for(var b=
-1,c=this.buffer.byteLength,d,f="",e="",g="";b<c;){-1!==b&&(d=this.view[b],f=16>d?f+("0"+d.toString(16).toUpperCase()):f+d.toString(16).toUpperCase(),a&&(e+=32<d&&127>d?String.fromCharCode(d):"."));++b;if(a&&0<b&&0===b%16&&b!==c){for(;51>f.length;)f+=" ";g+=f+e+"\n";f=e=""}f=b===this.offset&&b===this.limit?f+(b===this.markedOffset?"!":"|"):b===this.offset?f+(b===this.markedOffset?"[":"<"):b===this.limit?f+(b===this.markedOffset?"]":">"):f+(b===this.markedOffset?"'":a||0!==b&&b!==c?" ":"")}if(a&&" "!==
f){for(;51>f.length;)f+=" ";g+=f+e+"\n"}return a?g:f};h.fromDebug=function(a,b,c){var d=a.length;b=new h((d+1)/3|0,b,c);for(var f=0,e=0,g,k=!1,m=!1,n=!1,p=!1,q=!1;f<d;){switch(g=a.charAt(f++)){case "!":if(!c){if(m||n||p){q=!0;break}m=n=p=!0}b.offset=b.markedOffset=b.limit=e;k=!1;break;case "|":if(!c){if(m||p){q=!0;break}m=p=!0}b.offset=b.limit=e;k=!1;break;case "[":if(!c){if(m||n){q=!0;break}m=n=!0}b.offset=b.markedOffset=e;k=!1;break;case "<":if(!c){if(m){q=!0;break}m=!0}b.offset=e;k=!1;break;case "]":if(!c){if(p||
n){q=!0;break}p=n=!0}b.limit=b.markedOffset=e;k=!1;break;case ">":if(!c){if(p){q=!0;break}p=!0}b.limit=e;k=!1;break;case "'":if(!c){if(n){q=!0;break}n=!0}b.markedOffset=e;k=!1;break;case " ":k=!1;break;default:if(!c&&k){q=!0;break}g=parseInt(g+a.charAt(f++),16);if(!c&&(isNaN(g)||0>g||255<g))throw TypeError("Illegal str: Not a debug encoded string");b.view[e++]=g;k=!0}if(q)throw TypeError("Illegal str: Invalid symbol at "+f);}if(!c){if(!m||!p)throw TypeError("Illegal str: Missing offset or limit");
if(e<b.buffer.byteLength)throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+e+" < "+d);}return b};e.toHex=function(a,b){a="undefined"===typeof a?this.offset:a;b="undefined"===typeof b?this.limit:b;if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+a+" <= "+b+" <= "+
this.buffer.byteLength);}for(var c=Array(b-a),d;a<b;)d=this.view[a++],16>d?c.push("0",d.toString(16)):c.push(d.toString(16));return c.join("")};h.fromHex=function(a,b,c){if(!c){if("string"!==typeof a)throw TypeError("Illegal str: Not a string");if(0!==a.length%2)throw TypeError("Illegal str: Length not a multiple of 2");}var d=a.length;b=new h(d/2|0,b);for(var f,e=0,g=0;e<d;e+=2){f=parseInt(a.substring(e,e+2),16);if(!c&&(!isFinite(f)||0>f||255<f))throw TypeError("Illegal str: Contains non-hex characters");
b.view[g++]=f}b.limit=g;return b};var n=function(){var a={MAX_CODEPOINT:1114111,encodeUTF8:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)128>d?c(d&127):(2048>d?c(d>>6&31|192):(65536>d?c(d>>12&15|224):(c(d>>18&7|240),c(d>>12&63|128)),c(d>>6&63|128)),c(d&63|128)),d=null},decodeUTF8:function(a,c){for(var d,f,e,g,h=function(a){a=a.slice(0,a.indexOf(null));var b=Error(a.toString());b.name="TruncatedError";b.bytes=a;throw b;};null!==(d=a());)if(0===
(d&128))c(d);else if(192===(d&224))null===(f=a())&&h([d,f]),c((d&31)<<6|f&63);else if(224===(d&240))null!==(f=a())&&null!==(e=a())||h([d,f,e]),c((d&15)<<12|(f&63)<<6|e&63);else if(240===(d&248))null!==(f=a())&&null!==(e=a())&&null!==(g=a())||h([d,f,e,g]),c((d&7)<<18|(f&63)<<12|(e&63)<<6|g&63);else throw RangeError("Illegal starting byte: "+d);},UTF16toUTF8:function(a,c){for(var d,e=null;null!==(d=null!==e?e:a());)55296<=d&&57343>=d&&null!==(e=a())&&56320<=e&&57343>=e?(c(1024*(d-55296)+e-56320+65536),
e=null):c(d);null!==e&&c(e)},UTF8toUTF16:function(a,c){var d=null;"number"===typeof a&&(d=a,a=function(){return null});for(;null!==d||null!==(d=a());)65535>=d?c(d):(d-=65536,c((d>>10)+55296),c(d%1024+56320)),d=null},encodeUTF16toUTF8:function(b,c){a.UTF16toUTF8(b,function(b){a.encodeUTF8(b,c)})},decodeUTF8toUTF16:function(b,c){a.decodeUTF8(b,function(b){a.UTF8toUTF16(b,c)})},calculateCodePoint:function(a){return 128>a?1:2048>a?2:65536>a?3:4},calculateUTF8:function(a){for(var c,d=0;null!==(c=a());)d+=
128>c?1:2048>c?2:65536>c?3:4;return d},calculateUTF16asUTF8:function(b){var c=0,d=0;a.UTF16toUTF8(b,function(a){++c;d+=128>a?1:2048>a?2:65536>a?3:4});return[c,d]}};return a}();e.toUTF8=function(a,b){"undefined"===typeof a&&(a=this.offset);"undefined"===typeof b&&(b=this.limit);if(!this.noAssert){if("number"!==typeof a||0!==a%1)throw TypeError("Illegal begin: Not an integer");a>>>=0;if("number"!==typeof b||0!==b%1)throw TypeError("Illegal end: Not an integer");b>>>=0;if(0>a||a>b||b>this.buffer.byteLength)throw RangeError("Illegal range: 0 <= "+
a+" <= "+b+" <= "+this.buffer.byteLength);}var c;try{n.decodeUTF8toUTF16(function(){return a<b?this.view[a++]:null}.bind(this),c=r())}catch(d){if(a!==b)throw RangeError("Illegal range: Truncated data, "+a+" != "+b);}return c()};h.fromUTF8=function(a,b,c){if(!c&&"string"!==typeof a)throw TypeError("Illegal str: Not a string");var d=new h(n.calculateUTF16asUTF8(m(a),!0)[1],b,c),e=0;n.encodeUTF16toUTF8(m(a),function(a){d.view[e++]=a});d.limit=e;return d};return h});

BIN
node_modules/bytebuffer/dist/bytebuffer.min.js.gz generated vendored Normal file

Binary file not shown.

8
node_modules/bytebuffer/dist/bytebuffer.min.map generated vendored Normal file

File diff suppressed because one or more lines are too long

BIN
node_modules/bytebuffer/donate.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

862
node_modules/bytebuffer/externs/bytebuffer.js generated vendored Normal file
View File

@ -0,0 +1,862 @@
/*
* Copyright 2012 The Closure Compiler Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Externs for ByteBuffer.js.
* @see https://github.com/dcodeIO/ByteBuffer.js
* @externs
*/
/**
BEGIN_NODE_INCLUDE
var ByteBuffer = require('bytebuffer');
END_NODE_INCLUDE
*/
/**
* @param {number=} capacity
* @param {boolean=} littleEndian
* @param {boolean=} sparse
* @constructor
*/
function ByteBuffer(capacity, littleEndian, sparse) {};
/**
* @type {?ArrayBuffer}
*/
ByteBuffer.prototype.array;
/**
* @type {number}
*/
ByteBuffer.prototype.offset;
/**
* @type {number}
*/
ByteBuffer.prototype.markedOffset;
/**
* @type {number}
*/
ByteBuffer.prototype.limit;
/**
* @type {boolean}
*/
ByteBuffer.prototype.littleEndian;
/**
* @type {string}
* @const
*/
ByteBuffer.VERSION;
/**
* @type {number}
* @const
*/
ByteBuffer.DEFAULT_CAPACITY = 32;
/**
* @type {boolean}
* @const
*/
ByteBuffer.LITTLE_ENDIAN = true;
/**
* @type {boolean}
* @const
*/
ByteBuffer.BIG_ENDIAN = false;
/**
* @param {number=} capacity
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
* @nosideeffects
*/
ByteBuffer.allocate = function(capacity, littleEndian) {};
/**
* @param {!ArrayBuffer|!Buffer|!{array: ArrayBuffer}|!{buffer: ArrayBuffer}|string} buffer
* @param {(string|boolean)=} enc
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.wrap = function(buffer, enc, littleEndian) {};
/**
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.LE = function(littleEndian) {};
/**
* @param {boolean=} bigEndian
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.BE = function(bigEndian) {};
/**
* @param {string} str
* @param {boolean} littleEndian
* @param {boolean} noAssert
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fromBase64 = function(str, littleEndian, noAssert) {};
/**
* @param {string} str
* @param {boolean} littleEndian
* @param {boolean} noAssert
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fromBinary = function(str, littleEndian, noAssert) {};
/**
* @param {string} str
* @param {boolean} littleEndian
* @param {boolean} noAssert
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fromDebug = function(str, littleEndian, noAssert) {};
/**
* @param {string} str
* @param {boolean} littleEndian
* @param {boolean} noAssert
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fromHex = function(str, littleEndian, noAssert) {};
/**
* @param {string} str
* @param {boolean} littleEndian
* @param {boolean} noAssert
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fromUTF8 = function(str, littleEndian, noAssert) {};
/**
* @param {number} capacity
* @returns {boolean}
*/
ByteBuffer.prototype.resize = function(capacity) {};
/**
* @param {number} begin
* @param {number} end
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.prototype.slice = function(begin, end) {};
/**
* @param {number} begin
* @param {number} end
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.prototype.sliceAndCompact = function(begin, end) {};
/**
* @param {number} capacity
* @returns {boolean}
*/
ByteBuffer.prototype.ensureCapacity = function(capacity) {};
/**
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.flip = function() {};
/**
* @param {number=} offset
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.mark = function(offset) {};
/**
* @returns {!ByteBuffer} this
*/
ByteBuffer.prototype.reset = function() {};
/**
* @returns {!ByteBuffer}
* @nosideeffects
*/
ByteBuffer.prototype.clone = function() {};
/**
* @returns {!ByteBuffer}
* @nosideeffects
*/
ByteBuffer.prototype.copy = function() {};
/**
* @returns {number}
* @nosideeffects
*/
ByteBuffer.prototype.remaining = function() {};
/**
* @returns {number}
* @nosideeffects
*/
ByteBuffer.prototype.capacity = function() {};
/**
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.compact = function() {};
/**
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.reverse = function() {};
/**
* @param {!ByteBuffer} src
* @param {number=} offset
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.append = function(src, offset) {};
/**
* @param {!ByteBuffer} src
* @param {number=} offset
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.prepend = function(src, offset) {};
/**
* @param {number|string} value
* @param {number} begin
* @param {number} end
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.fill = function(value, begin, end) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeInt8 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readInt8 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeByte = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readByte = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeUint8 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readUint8 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeInt16 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readInt16 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeShort = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readShort = function (offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeUint16 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readUint16 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeInt32 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readInt32 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeInt = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readInt = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeUint32 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readUint32 = function(offset) {};
/**
* @param {number|Long} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeInt64 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {Long}
* @throws {Error}
*/
ByteBuffer.prototype.readInt64 = function(offset) {};
/**
* @param {number|Long} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeUint64 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {Long}
* @throws {Error}
*/
ByteBuffer.prototype.readUint64 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeFloat32 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readFloat32 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeFloat = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readFloat = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeFloat64 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readFloat64 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeDouble = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readDouble = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeLong = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.prototype.readLong = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeVarint32 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number|!{value: number, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readVarint32 = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeZigZagVarint32 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number|{value: number, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readZigZagVarint32 = function(offset) {};
/**
* @param {number|Long} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
* @throws {Error}
*/
ByteBuffer.prototype.writeVarint64 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {!Long|{value: !Long, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readVarint64 = function(offset) {};
/**
* @param {number|Long} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
* @throws {Error}
*/
ByteBuffer.prototype.writeZigZagVarint64 = function(value, offset) {};
/**
* @param {number=} offset
* @returns {!Long|!{value: !Long, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readZigZagVarint64 = function(offset) {};
/**
* @param {number|Long} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
* @throws {Error}
*/
ByteBuffer.prototype.writeVarint64ZigZag = function(value, offset) {};
/**
* @param {number=} offset
* @returns {!Long|{value: !Long, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readVarint64ZigZag = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeVarint = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number|!{value: number, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readVarint = function(offset) {};
/**
* @param {number} value
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeZigZagVarint = function(value, offset) {};
/**
* @param {number=} offset
* @returns {number|{value: number, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readZigZagVarint = function(offset) {};
/**
* @param {number} value
* @returns {number}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.calculateVarint32 = function(value) {};
/**
* @param {number} value
* @returns {number}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.calculateVarint64 = function(value) {};
/**
* @param {string} str
* @returns {number}
* @nosideeffects
*/
ByteBuffer.calculateUTF8String = function(str) {};
/**
* @param {string} str
* @returns {number}
*/
ByteBuffer.prototype.calculateUTF8Bytes = function(str) {};
/**
* @param {string} str
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeUTF8String = function(str, offset) {};
/**
* @param {number} chars
* @param {number=} offset
* @returns {string|!{string: string, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readUTF8String = function(chars, offset) {};
/**
* @param {number} length
* @param {number} offset
* @throws {Error}
*/
ByteBuffer.prototype.readUTF8StringBytes = function(length, offset) {};
/**
* @param {string} str
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeLString = function(str, offset) {};
/**
* @param {number=} offset
* @returns {string|!{string: string, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readLString = function(offset) {};
/**
* @param {string} str
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeVString = function(str, offset) {};
/**
* @param {number=} offset
* @returns {string|!{string: string, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readVString = function(offset) {};
/**
* @param {string} str
* @param {number=} offset
* @returns {!ByteBuffer|number}
*/
ByteBuffer.prototype.writeCString = function(str, offset) {};
/**
* @param {number=} offset
* @returns {string|!{string: string, length: number}}
* @throws {Error}
*/
ByteBuffer.prototype.readCString = function(offset) {};
/**
* @param {number} length
* @param {number=} offset
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.readBytes = function(length, offset) {};
/**
* @param {!ByteBuffer} src
* @param {number=} offset
* @returns {!ByteBuffer}
* @throws {Error}
*/
ByteBuffer.prototype.writeBytes = function(src, offset) {};
/**
* @param {number=} offset
* @returns {Array<boolean>}
*/
ByteBufferPrototype.readBitSet = function(offset) {};
/**
* @param {Array<boolean>}
* @param {number=}
* @returns {!ByteBuffer}
*/
ByteBuffer.prototype.writeBitSet = function(value, offset) {};
/**
* @param {number=} wrap
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toColumns = function(wrap) {};
/**
* @param {function(string)=} out
*/
ByteBuffer.prototype.printDebug = function(out) {};
/**
* @param {boolean=} debug
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toHex = function(debug) {};
/**
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toBinary = function() {};
/**
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toUTF8 = function() {};
/**
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toBase64 = function() {};
/**
* @param {string=} enc
* @returns {string}
* @nosideeffects
*/
ByteBuffer.prototype.toString = function(enc) {};
/**
* @param {boolean=} forceCopy
* @returns {ArrayBuffer}
* @nosideeffects
*/
ByteBuffer.prototype.toArrayBuffer = function(forceCopy) {};
/**
* @param {!ByteBuffer} src
* @param {number} offset
* @returns {!{char: number, length: number}}
* @nosideeffects
*/
ByteBuffer.decodeUTF8Char = function(src, offset) {};
/**
* @param {number} charCode
* @param {!ByteBuffer} dst
* @param {number} offset
* @returns {number}
* @throws {Error}
*/
ByteBuffer.encodeUTF8Char = function(charCode, dst, offset) {};
/**
* @param {number} charCode
* @returns {number}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.calculateUTF8Char = function(charCode) {};
/**
* @param {number} n
* @returns {number}
* @nosideeffects
*/
ByteBuffer.zigZagEncode32 = function(n) {};
/**
* @param {number} n
* @returns {number}
* @nosideeffects
*/
ByteBuffer.zigZagDecode32 = function(n) {};
/**
* @param {!ByteBuffer} bb
* @returns {string}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.encode64 = function(bb) {};
/**
* @param {string} str
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.decode64 = function(str, littleEndian) {};
/**
* @param {!ByteBuffer} bb
* @returns {string}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.encodeHex = function(bb) {};
/**
* @param {string} str
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.decodeHex = function(str, littleEndian) {};
/**
* @param {!ByteBuffer} bb
* @returns {string}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.encodeBinary = function(bb) {};
/**
* @param {string} str
* @param {boolean=} littleEndian
* @returns {!ByteBuffer}
* @throws {Error}
* @nosideeffects
*/
ByteBuffer.decodeBinary = function(str, littleEndian) {};
/**
* @type {number}
* @const
*/
ByteBuffer.MAX_VARINT32_BYTES = 5;
/**
* @type {number}
* @const
*/
ByteBuffer.MAX_VARINT64_BYTES = 10;

52
node_modules/bytebuffer/externs/minimal-env.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
/**
* @param {string} moduleName
* @returns {?}
*/
function require(moduleName) {};
/**
* @param {string} name
* @param {Array.<string>} deps
* @param {function(...[*])} f
*/
function define(name, deps, f) {};
/**
* @param {number} size
* @constructor
* @extends Array
*/
function Buffer(size) {};
/**
* @param {*} buf
* @return {boolean}
*/
Buffer.isBuffer = function(buf) {};
/**
* @type {Object.<string,*>}
*/
var console = {};
/**
* @param {string} s
*/
console.log = function(s) {};
/**
* @type {*}
*/
var module = {};
/**
* @param {...*} var_args
* @returns {string}
*/
String.fromCodePoint = function(var_args) {};
/**
* @param {number} offset
* @returns {number}
*/
String.prototype.codePointAt = function(offset) {};

1
node_modules/bytebuffer/index.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require("./dist/bytebuffer-node.js");

13
node_modules/bytebuffer/jsdoc.json generated vendored Normal file
View File

@ -0,0 +1,13 @@
{
"tags": {
"allowUnknownTags": true
},
"source": {
"include": ["dist/ByteBufferAB.js"]
},
"opts": {
"template": "templates/esoccer",
"destination": "docs"
},
"plugins": ["plugins/markdown"]
}

80
node_modules/bytebuffer/package.json generated vendored Normal file
View File

@ -0,0 +1,80 @@
{
"_from": "bytebuffer@~5",
"_id": "bytebuffer@5.0.1",
"_inBundle": false,
"_integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=",
"_location": "/bytebuffer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "bytebuffer@~5",
"name": "bytebuffer",
"escapedName": "bytebuffer",
"rawSpec": "~5",
"saveSpec": null,
"fetchSpec": "~5"
},
"_requiredBy": [
"/protobufjs"
],
"_resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz",
"_shasum": "582eea4b1a873b6d020a48d58df85f0bba6cfddd",
"_spec": "bytebuffer@~5",
"_where": "/home/sergiu/linx-audio-simulator/node_modules/protobufjs",
"author": {
"name": "Daniel Wirtz",
"email": "dcode@dcode.io"
},
"browser": "dist/bytebuffer.js",
"bugs": {
"url": "https://github.com/dcodeIO/bytebuffer.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"long": "~3"
},
"deprecated": false,
"description": "The swiss army knife for binary data in JavaScript.",
"devDependencies": {
"closurecompiler": "~1",
"lxiv": "~0.2",
"metascript": "~0",
"pretty-hrtime": "^1.0.0",
"testjs": "~1",
"utfx": "^1.0.1"
},
"engines": {
"node": ">=0.8"
},
"homepage": "https://github.com/dcodeIO/bytebuffer.js#readme",
"keywords": [
"net",
"array",
"buffer",
"arraybuffer",
"typed array",
"bytebuffer",
"json",
"websocket",
"webrtc"
],
"license": "Apache-2.0",
"main": "dist/bytebuffer-node.js",
"name": "bytebuffer",
"repository": {
"type": "git",
"url": "git+https://github.com/dcodeIO/bytebuffer.js.git"
},
"scripts": {
"build": "node scripts/build.js",
"compile": "npm run-script compile-default && npm run-script compile-dataview",
"compile-dataview": "ccjs dist/bytebuffer-dataview.js --create_source_map=dist/bytebuffer-dataview.min.map --externs=externs/minimal-env.js --externs=node_modules/long/externs/long.js > dist/bytebuffer-dataview.min.js",
"compile-default": "ccjs dist/bytebuffer.js --create_source_map=dist/bytebuffer.min.map --externs=externs/minimal-env.js --externs=node_modules/long/externs/long.js > dist/bytebuffer.min.js",
"compress": "gzip -c -9 dist/bytebuffer.min.js > dist/bytebuffer.min.js.gz && gzip -c -9 dist/bytebuffer-dataview.min.js > dist/bytebuffer-dataview.min.js.gz",
"make": "npm run-script build && npm run-script compile && npm run-script compress && npm test",
"prepublish": "npm test",
"test": "node node_modules/testjs/bin/testjs tests/suite.js"
},
"version": "5.0.1"
}

113
node_modules/bytebuffer/scripts/build.js generated vendored Normal file
View File

@ -0,0 +1,113 @@
/*
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var MetaScript = require("metascript"),
path = require("path"),
fs = require("fs");
var rootDir = path.join(__dirname, ".."),
srcDir = path.join(__dirname, "..", "src"),
distDir = path.join(__dirname, "..", "dist"),
pkg = require(path.join(rootDir, "package.json")),
filename;
var scope = {
VERSION : pkg.version, // Version
// Encodings
ENCODINGS : true, // Include encodings in general (catches all)
BASE64 : true, // Include base64 encoding
BINARY : true, // Include binary encoding
DEBUG : true, // Include debug encoding
HEX : true, // Include hex encoding
UTF8 : true, // Include utf8 encoding (required for STRINGS)
// Primitive types
BYTES : true, // Include bytes
INTS : true, // Include int types in general (catches all)
INT8 : true, // Include int8/uint8
INT16 : true, // Include int16/uint16
INT32 : true, // Include int32/uint32
INT64 : true, // Include int64/uint64 with Long.js
FLOATS : true, // Include float types in general (catches all)
FLOAT32 : true, // Include float32
FLOAT64 : true, // Include float64
// Varint encoding
VARINTS : true, // Include varint encoding in general (catches all)
VARINT32 : true, // Include varint32/zigZagVarint32
VARINT64 : true, // Include varint64/zigZagVarint32 with Long.js
// String support
STRINGS : true, // Include string support in general (catches all)
UTF8STRING : true, // Include UTF8 encoded strings
CSTRING : true, // Include C-like null terminated strings
VSTRING : true, // Include varint32 length prefixed strings
ISTRING : true, // Include uint32 length prefixed strings
// Other
ALIASES : true, // Include aliases like writeByte, writeShort ..
INLINE : true, // Inline any assertion code
VERBOSE_MS : false // Include MetaScript details as comments
};
// Optimize for size : INLINE=false, ALIASES=false, VERBOSE_MS=false, WHATEVERYOUDONTNEED=false
// Optimize for speed : INLINE=true
if (!scope.UTF8) scope.STRINGS = false;
// Build node version using Buffers
scope.NODE = true;
console.log("Building bytebuffer-node with scope", JSON.stringify(scope, null, 2));
fs.writeFileSync(
path.join(distDir, "bytebuffer-node.js"),
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap-node.js")), filename, scope, srcDir)
);
// Build browser version using Typed Arrays
scope.NODE = false;
scope.DATAVIEW = false;
delete scope.BUFFERVIEW;
console.log("Building bytebuffer.js with scope", JSON.stringify(scope, null, 2));
fs.writeFileSync(
path.join(distDir, "bytebuffer.js"),
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope)
);
// Build alternative browser version using a DataView
scope.NODE = false;
scope.DATAVIEW = true;
console.log("Building bytebuffer-dataview with scope", JSON.stringify(scope, null, 2));
fs.writeFileSync(
path.join(distDir, "bytebuffer-dataview.js"),
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope)
);
// Update bower.json
scope = { VERSION: pkg.version };
console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));
fs.writeFileSync(
path.join(rootDir, "bower.json"),
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json")), filename, scope, srcDir)
);
console.log("Done");

12
node_modules/bytebuffer/src/bower.json generated vendored Normal file
View File

@ -0,0 +1,12 @@
{
"name": "bytebuffer",
"version": "/*?= VERSION */",
"author": "Daniel Wirtz <dcode@dcode.io>",
"description": "A full-featured ByteBuffer implementation using typed arrays.",
"main": "dist/bytebuffer.js",
"keywords": ["net", "array", "buffer", "arraybuffer", "typed array", "bytebuffer", "json", "websocket", "webrtc"],
"dependencies": {
"long": "latest"
},
"license": "Apache-2.0"
}

220
node_modules/bytebuffer/src/bytebuffer.js generated vendored Normal file
View File

@ -0,0 +1,220 @@
//? include("macros.js");
/**
* Constructs a new ByteBuffer.
* @class The swiss army knife for binary data in JavaScript.
* @exports ByteBuffer
* @constructor
* @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @expose
*/
var ByteBuffer = function(capacity, littleEndian, noAssert) {
if (typeof capacity === 'undefined')
capacity = ByteBuffer.DEFAULT_CAPACITY;
if (typeof littleEndian === 'undefined')
littleEndian = ByteBuffer.DEFAULT_ENDIAN;
if (typeof noAssert === 'undefined')
noAssert = ByteBuffer.DEFAULT_NOASSERT;
if (!noAssert) {
capacity = capacity | 0;
if (capacity < 0)
throw RangeError("Illegal capacity");
littleEndian = !!littleEndian;
noAssert = !!noAssert;
}
//? if (NODE) {
/**
* Backing node Buffer.
* @type {!Buffer}
* @expose
*/
this.buffer = capacity === 0 ? EMPTY_BUFFER : new Buffer(capacity);
//? } else {
/**
* Backing ArrayBuffer.
* @type {!ArrayBuffer}
* @expose
*/
this.buffer = capacity === 0 ? EMPTY_BUFFER : new ArrayBuffer(capacity);
//? if (DATAVIEW) {
/**
* DataView utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`.
* @type {?DataView}
* @expose
*/
this.view = capacity === 0 ? null : new DataView(this.buffer);
//? } else {
/**
* Uint8Array utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`.
* @type {?Uint8Array}
* @expose
*/
this.view = capacity === 0 ? null : new Uint8Array(this.buffer);
//? }
//? }
/**
* Absolute read/write offset.
* @type {number}
* @expose
* @see ByteBuffer#flip
* @see ByteBuffer#clear
*/
this.offset = 0;
/**
* Marked offset.
* @type {number}
* @expose
* @see ByteBuffer#mark
* @see ByteBuffer#reset
*/
this.markedOffset = -1;
/**
* Absolute limit of the contained data. Set to the backing buffer's capacity upon allocation.
* @type {number}
* @expose
* @see ByteBuffer#flip
* @see ByteBuffer#clear
*/
this.limit = capacity;
/**
* Whether to use little endian byte order, defaults to `false` for big endian.
* @type {boolean}
* @expose
*/
this.littleEndian = littleEndian;
/**
* Whether to skip assertions of offsets and values, defaults to `false`.
* @type {boolean}
* @expose
*/
this.noAssert = noAssert;
};
/**
* ByteBuffer version.
* @type {string}
* @const
* @expose
*/
ByteBuffer.VERSION = "/*?= VERSION */";
/**
* Little endian constant that can be used instead of its boolean value. Evaluates to `true`.
* @type {boolean}
* @const
* @expose
*/
ByteBuffer.LITTLE_ENDIAN = true;
/**
* Big endian constant that can be used instead of its boolean value. Evaluates to `false`.
* @type {boolean}
* @const
* @expose
*/
ByteBuffer.BIG_ENDIAN = false;
/**
* Default initial capacity of `16`.
* @type {number}
* @expose
*/
ByteBuffer.DEFAULT_CAPACITY = 16;
/**
* Default endianess of `false` for big endian.
* @type {boolean}
* @expose
*/
ByteBuffer.DEFAULT_ENDIAN = ByteBuffer.BIG_ENDIAN;
/**
* Default no assertions flag of `false`.
* @type {boolean}
* @expose
*/
ByteBuffer.DEFAULT_NOASSERT = false;
//? if (NODE) {
/**
* A `Long` class for representing a 64-bit two's-complement integer value.
* @type {!Long}
* @const
* @see https://npmjs.org/package/long
* @expose
*/
ByteBuffer.Long = Long;
//? } else {
/**
* A `Long` class for representing a 64-bit two's-complement integer value. May be `null` if Long.js has not been loaded
* and int64 support is not available.
* @type {?Long}
* @const
* @see https://github.com/dcodeIO/long.js
* @expose
*/
ByteBuffer.Long = Long || null;
//? }
/**
* @alias ByteBuffer.prototype
* @inner
*/
var ByteBufferPrototype = ByteBuffer.prototype;
/**
* An indicator used to reliably determine if an object is a ByteBuffer or not.
* @type {boolean}
* @const
* @expose
* @private
*/
ByteBufferPrototype.__isByteBuffer__;
Object.defineProperty(ByteBufferPrototype, "__isByteBuffer__", {
value: true,
enumerable: false,
configurable: false
});
//? include("helpers.js");
//? include("methods/static/*.js");
//? if (BYTES) {
//? include("types/bytes/*.js");
//? }
//? if (INTS) {
//? include("types/ints/*.js");
//? }
//? if (FLOATS) {
//? include("types/floats/float*.js");
//? }
//? if (VARINTS) {
//? include("types/varints/*.js");
//? }
//? if (UTF8 && STRINGS) {
//? include("types/strings/*.js");
//? }
//? include("methods/*.js");
//? if (ENCODINGS) {
//? include("encodings/*.js");
//? }

88
node_modules/bytebuffer/src/encodings/base64.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
//? if (BASE64) {
//? if (!NODE) {
// lxiv-embeddable
//? include("../../node_modules/lxiv/dist/lxiv-embeddable.js");
//? }
// encodings/base64
/**
* Encodes this ByteBuffer's contents to a base64 encoded string.
* @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset}.
* @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}.
* @returns {string} Base64 encoded string
* @throws {RangeError} If `begin` or `end` is out of bounds
* @expose
*/
ByteBufferPrototype.toBase64 = function(begin, end) {
if (typeof begin === 'undefined')
begin = this.offset;
if (typeof end === 'undefined')
end = this.limit;
begin = begin | 0; end = end | 0;
if (begin < 0 || end > this.capacity || begin > end)
throw RangeError("begin, end");
//? if (NODE)
return this.buffer.toString("base64", begin, end);
//? else {
var sd; lxiv.encode(function() {
//? if (DATAVIEW)
return begin < end ? this.view.getUint8(begin++) : null;
//? else
return begin < end ? this.view[begin++] : null;
}.bind(this), sd = stringDestination());
return sd();
//? }
};
/**
* Decodes a base64 encoded string to a ByteBuffer.
* @param {string} str String to decode
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @returns {!ByteBuffer} ByteBuffer
* @expose
*/
ByteBuffer.fromBase64 = function(str, littleEndian) {
//? if (NODE) {
return ByteBuffer.wrap(new Buffer(str, "base64"), littleEndian);
//? } else {
if (typeof str !== 'string')
throw TypeError("str");
var bb = new ByteBuffer(str.length/4*3, littleEndian),
i = 0;
lxiv.decode(stringSource(str), function(b) {
//? if (DATAVIEW)
bb.view.setUint8(i++, b);
//? else
bb.view[i++] = b;
});
bb.limit = i;
//? }
return bb;
};
/**
* Encodes a binary string to base64 like `window.btoa` does.
* @param {string} str Binary string
* @returns {string} Base64 encoded string
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa
* @expose
*/
ByteBuffer.btoa = function(str) {
return ByteBuffer.fromBinary(str).toBase64();
};
/**
* Decodes a base64 encoded string to binary like `window.atob` does.
* @param {string} b64 Base64 encoded string
* @returns {string} Binary string
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window.atob
* @expose
*/
ByteBuffer.atob = function(b64) {
return ByteBuffer.fromBase64(b64).toBinary();
};
//? }

74
node_modules/bytebuffer/src/encodings/binary.js generated vendored Normal file
View File

@ -0,0 +1,74 @@
//? if (BINARY) {
// encodings/binary
/**
* Encodes this ByteBuffer to a binary encoded string, that is using only characters 0x00-0xFF as bytes.
* @param {number=} begin Offset to begin at. Defaults to {@link ByteBuffer#offset}.
* @param {number=} end Offset to end at. Defaults to {@link ByteBuffer#limit}.
* @returns {string} Binary encoded string
* @throws {RangeError} If `offset > limit`
* @expose
*/
ByteBufferPrototype.toBinary = function(begin, end) {
if (typeof begin === 'undefined')
begin = this.offset;
if (typeof end === 'undefined')
end = this.limit;
begin |= 0; end |= 0;
if (begin < 0 || end > this.capacity() || begin > end)
throw RangeError("begin, end");
//? if (NODE)
return this.buffer.toString("binary", begin, end);
//? else {
if (begin === end)
return "";
var chars = [],
parts = [];
while (begin < end) {
//? if (NODE)
chars.push(this.buffer[begin++]);
//? else if (DATAVIEW)
chars.push(this.view.getUint8(begin++));
//? else
chars.push(this.view[begin++]);
if (chars.length >= 1024)
parts.push(String.fromCharCode.apply(String, chars)),
chars = [];
}
return parts.join('') + String.fromCharCode.apply(String, chars);
//? }
};
/**
* Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteBuffer.
* @param {string} str String to decode
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @returns {!ByteBuffer} ByteBuffer
* @expose
*/
ByteBuffer.fromBinary = function(str, littleEndian) {
//? if (NODE) {
return ByteBuffer.wrap(new Buffer(str, "binary"), littleEndian);
//? } else {
if (typeof str !== 'string')
throw TypeError("str");
var i = 0,
k = str.length,
charCode,
bb = new ByteBuffer(k, littleEndian);
while (i<k) {
charCode = str.charCodeAt(i);
if (charCode > 0xff)
throw RangeError("illegal char code: "+charCode);
//? if (DATAVIEW)
bb.view.setUint8(i++, charCode);
//? else
bb.view[i++] = charCode;
}
bb.limit = k;
//? }
return bb;
};
//? }

211
node_modules/bytebuffer/src/encodings/debug.js generated vendored Normal file
View File

@ -0,0 +1,211 @@
//? if (DEBUG) {
// encodings/debug
/**
* Encodes this ByteBuffer to a hex encoded string with marked offsets. Offset symbols are:
* * `<` : offset,
* * `'` : markedOffset,
* * `>` : limit,
* * `|` : offset and limit,
* * `[` : offset and markedOffset,
* * `]` : markedOffset and limit,
* * `!` : offset, markedOffset and limit
* @param {boolean=} columns If `true` returns two columns hex + ascii, defaults to `false`
* @returns {string|!Array.<string>} Debug string or array of lines if `asArray = true`
* @expose
* @example `>00'01 02<03` contains four bytes with `limit=0, markedOffset=1, offset=3`
* @example `00[01 02 03>` contains four bytes with `offset=markedOffset=1, limit=4`
* @example `00|01 02 03` contains four bytes with `offset=limit=1, markedOffset=-1`
* @example `|` contains zero bytes with `offset=limit=0, markedOffset=-1`
*/
ByteBufferPrototype.toDebug = function(columns) {
var i = -1,
//? if (NODE)
k = this.buffer.length,
//? else
k = this.buffer.byteLength,
b,
hex = "",
asc = "",
out = "";
while (i<k) {
if (i !== -1) {
//? if (NODE)
b = this.buffer[i];
//? else if (DATAVIEW)
b = this.view.getUint8(i);
//? else
b = this.view[i];
if (b < 0x10) hex += "0"+b.toString(16).toUpperCase();
else hex += b.toString(16).toUpperCase();
if (columns)
asc += b > 32 && b < 127 ? String.fromCharCode(b) : '.';
}
++i;
if (columns) {
if (i > 0 && i % 16 === 0 && i !== k) {
while (hex.length < 3*16+3) hex += " ";
out += hex+asc+"\n";
hex = asc = "";
}
}
if (i === this.offset && i === this.limit)
hex += i === this.markedOffset ? "!" : "|";
else if (i === this.offset)
hex += i === this.markedOffset ? "[" : "<";
else if (i === this.limit)
hex += i === this.markedOffset ? "]" : ">";
else
hex += i === this.markedOffset ? "'" : (columns || (i !== 0 && i !== k) ? " " : "");
}
if (columns && hex !== " ") {
while (hex.length < 3*16+3)
hex += " ";
out += hex + asc + "\n";
}
return columns ? out : hex;
};
/**
* Decodes a hex encoded string with marked offsets to a ByteBuffer.
* @param {string} str Debug string to decode (not be generated with `columns = true`)
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer} ByteBuffer
* @expose
* @see ByteBuffer#toDebug
*/
ByteBuffer.fromDebug = function(str, littleEndian, noAssert) {
/*?
// "<60 61 62 63>"; // 13 = 4
// "60<61 62]63" // 11 = 4
// "<61 61 61>"; // 10 = 3 => C = ((L+1)/3) | 0
// "61<61>61"; // 8 = 3
// "<61 61>"; // 7 = 2
*/
var k = str.length,
bb = new ByteBuffer(((k+1)/3)|0, littleEndian, noAssert);
var i = 0, j = 0, ch, b,
rs = false, // Require symbol next
ho = false, hm = false, hl = false, // Already has offset (ho), markedOffset (hm), limit (hl)?
fail = false;
while (i<k) {
switch (ch = str.charAt(i++)) {
case '!':
if (!noAssert) {
if (ho || hm || hl) {
fail = true;
break;
}
ho = hm = hl = true;
}
bb.offset = bb.markedOffset = bb.limit = j;
rs = false;
break;
case '|':
if (!noAssert) {
if (ho || hl) {
fail = true;
break;
}
ho = hl = true;
}
bb.offset = bb.limit = j;
rs = false;
break;
case '[':
if (!noAssert) {
if (ho || hm) {
fail = true;
break;
}
ho = hm = true;
}
bb.offset = bb.markedOffset = j;
rs = false;
break;
case '<':
if (!noAssert) {
if (ho) {
fail = true;
break;
}
ho = true;
}
bb.offset = j;
rs = false;
break;
case ']':
if (!noAssert) {
if (hl || hm) {
fail = true;
break;
}
hl = hm = true;
}
bb.limit = bb.markedOffset = j;
rs = false;
break;
case '>':
if (!noAssert) {
if (hl) {
fail = true;
break;
}
hl = true;
}
bb.limit = j;
rs = false;
break;
case "'":
if (!noAssert) {
if (hm) {
fail = true;
break;
}
hm = true;
}
bb.markedOffset = j;
rs = false;
break;
case ' ':
rs = false;
break;
default:
if (!noAssert) {
if (rs) {
fail = true;
break;
}
}
b = parseInt(ch+str.charAt(i++), 16);
if (!noAssert) {
if (isNaN(b) || b < 0 || b > 255)
throw TypeError("Illegal str: Not a debug encoded string");
}
//? if (NODE)
bb.buffer[j++] = b;
//? else if (DATAVIEW)
bb.view.setUint8(j++, b);
//? else
bb.view[j++] = b;
rs = true;
}
if (fail)
throw TypeError("Illegal str: Invalid symbol at "+i);
}
if (!noAssert) {
if (!ho || !hl)
throw TypeError("Illegal str: Missing offset or limit");
//? if (NODE)
if (j<bb.buffer.length)
//? else
if (j<bb.buffer.byteLength)
throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+j+" < "+k);
}
return bb;
};
//? }

75
node_modules/bytebuffer/src/encodings/hex.js generated vendored Normal file
View File

@ -0,0 +1,75 @@
//? if (HEX) {
// encodings/hex
/**
* Encodes this ByteBuffer's contents to a hex encoded string.
* @param {number=} begin Offset to begin at. Defaults to {@link ByteBuffer#offset}.
* @param {number=} end Offset to end at. Defaults to {@link ByteBuffer#limit}.
* @returns {string} Hex encoded string
* @expose
*/
ByteBufferPrototype.toHex = function(begin, end) {
begin = typeof begin === 'undefined' ? this.offset : begin;
end = typeof end === 'undefined' ? this.limit : end;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
//? if (NODE)
return this.buffer.toString("hex", begin, end);
//? else {
var out = new Array(end - begin),
b;
while (begin < end) {
//? if (DATAVIEW)
b = this.view.getUint8(begin++);
//? else
b = this.view[begin++];
if (b < 0x10)
out.push("0", b.toString(16));
else out.push(b.toString(16));
}
return out.join('');
//? }
};
/**
* Decodes a hex encoded string to a ByteBuffer.
* @param {string} str String to decode
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer} ByteBuffer
* @expose
*/
ByteBuffer.fromHex = function(str, littleEndian, noAssert) {
if (!noAssert) {
if (typeof str !== 'string')
throw TypeError("Illegal str: Not a string");
if (str.length % 2 !== 0)
throw TypeError("Illegal str: Length not a multiple of 2");
}
//? if (NODE) {
var bb = new ByteBuffer(0, littleEndian, true);
bb.buffer = new Buffer(str, "hex");
bb.limit = bb.buffer.length;
//? } else {
var k = str.length,
bb = new ByteBuffer((k / 2) | 0, littleEndian),
b;
for (var i=0, j=0; i<k; i+=2) {
b = parseInt(str.substring(i, i+2), 16);
if (!noAssert)
if (!isFinite(b) || b < 0 || b > 255)
throw TypeError("Illegal str: Contains non-hex characters");
//? if (DATAVIEW)
bb.view.setUint8(j++, b);
//? else
bb.view[j++] = b;
}
bb.limit = j;
//? }
return bb;
};
//? }

3
node_modules/bytebuffer/src/encodings/impl/base64.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
// encodings/impl/base64
// TODO

65
node_modules/bytebuffer/src/encodings/impl/binary.js generated vendored Normal file
View File

@ -0,0 +1,65 @@
// encodings/impl/binary
/**
* Encodes a binary JavaScript string to bytes.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {!ByteBuffer} dst Destination ByteBuffer
* @param {number} dstOffset Destination offset
* @param {number} count Number of char codes to encode
* @returns {number} Number of bytes encoded
* @inner
*/
function binary_encode(src, srcOffset, dst, dstOffset, count) {
var n = 0;
while (count--) {
var cc = src.charCodeAt(srcOffset++);
if (cc > 255)
throw Error("illegal binary char code: "+cc);
//? SET('cc', 'dstOffset++', 'dst');
++n;
}
return n;
}
/**
* Decodes bytes to a binary JavaScript string.
* @param {!ByteBuffer} src Source ByteBuffer
* @param {number} srcOffset Source offset
* @param {number} count Number of bytes to decode
* @returns {string} Decoded string
* @inner
*/
function binary_decode(src, srcOffset, count) {
if (count === 0)
return "";
var parts = [], // readily assembled parts
batch = []; // char codes for batch processing
while (count--) {
batch.push(/*? GET('srcOffset++', 'src') */);
if (batch.length > 1023) {
parts.push(String.fromCharCode.apply(String, batch));
batch.length = 0;
}
}
if (batch.length > 0) {
if (parts.length === 0)
return String.fromCharCode.apply(String, batch);
parts.push(String.fromCharCode.apply(String, batch));
}
return parts.join('');
}
/**
* Calculates the number of bytes required to store a binary JavaScript string.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {number} count Number of char codes to calculate
* @returns {number} Number of bytes required
* @inner
*/
function binary_calculate(src, srcOffset, count) {
return count;
}
ByteBuffer.registerEncoding("binary", binary_encode, binary_decode, binary_calculate);

3
node_modules/bytebuffer/src/encodings/impl/debug.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
// encodings/impl/debug
// TODO

101
node_modules/bytebuffer/src/encodings/impl/hex.js generated vendored Normal file
View File

@ -0,0 +1,101 @@
// encodings/impl/hex
/**
* Encodes a hexadecimal JavaScript string to bytes.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {!ByteBuffer} dst Destination ByteBuffer
* @param {number} dstOffset Destination offset
* @param {number} count Number of char codes to encode
* @returns {number} Number of bytes encoded
* @inner
*/
function hex_encode(src, srcOffset, dst, dstOffset, count) {
if (count === 0)
return 0;
var n = 0;
while (count--) {
if (count === 0)
throw Error("truncated hex sequence");
--count;
var value = 0,
shift = 0;
for (var i=0; i<2; ++i) {
var cc = src.charCodeAt(srcOffset++);
switch (cc) {
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
value |= (cc - 0x30) << shift;
break;
case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46:
value |= (cc - 0x4B) << shift;
break;
case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66:
value |= (cc - 0x6B) << shift;
break;
default:
throw Error("illegal hex char code: "+cc);
}
shift += 4;
}
//? SET('value', 'dstOffset++', 'dst');
++n;
}
return n;
}
/**
* Decodes bytes to a hexadecimal JavaScript string.
* @param {!ByteBuffer} src Source ByteBuffer
* @param {number} srcOffset Source offset
* @param {number} count Number of bytes to decode
* @returns {string} Decoded string
* @inner
*/
function hex_decode(src, srcOffset, count) {
if (count === 0)
return "";
var parts = [], // readily assembled parts
batch = []; // char codes for batch processing
while (count--) {
var value = /*? GET('srcOffset++', 'src') */,
shift = 4;
for (var i=0; i<2; ++i) {
var c = (value >>> shift) & 0xf;
switch (c) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9:
batch.push(0x30 + c);
break;
case 10: case 11: case 12: case 13: case 14: case 15:
batch.push(0x37 + c);
break;
}
shift = 0;
}
if (batch.length > 1023) {
parts.push(String.fromCharCode.apply(String, batch));
batch.length = 0;
}
}
if (batch.length > 0) {
if (parts.length === 0)
return String.fromCharCode.apply(String, batch);
parts.push(String.fromCharCode.apply(String, batch));
}
return parts.join('');
}
/**
* Calculates the number of bytes required to store a hexadecimal JavaScript string.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {number} count Number of char codes to calculate
* @returns {number} Number of bytes required
* @inner
*/
function hex_calculate(src, srcOffset, count) {
if ((count % 2) !== 0)
throw Error("illegal number of hex char codes: "+count);
return count / 2;
}
ByteBuffer.registerEncoding("hex", hex_encode, hex_decode, hex_calculate);

126
node_modules/bytebuffer/src/encodings/impl/utf8.js generated vendored Normal file
View File

@ -0,0 +1,126 @@
// encodings/impl/utf8
/**
* Encodes a standard JavaScript string to UTF8 bytes.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {!ByteBuffer} dst Destination ByteBuffer
* @param {number} dstOffset Destination offset
* @param {number} count Number of char codes to encode
* @returns {number} Number of bytes encoded
* @inner
*/
function utf8_encode(src, srcOffset, dst, dstOffset, count) {
if (count === 0)
return 0;
var n = 0;
//? // SET(varValue, varOffset, varTarget) with varTarget referencing a ByteBuffer
do {
var cc = src.charCodeAt(srcOffset++);
--count;
if (cc < 0x80) {
n += 1;
//? SET('cc', 'dstOffset++', 'dst');
} else if (cc < 0x800) {
n += 2;
//? SET('0xC0 | (cc >> 6)', 'dstOffset++', 'dst');
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
} else if (cc < 0xD800 || cc >= 0xE000) {
n += 3;
//? SET('0xE0 | (cc >> 12)', 'dstOffset++', 'dst');
//? SET('0x80 | ((cc >> 6) & 0x3F)', 'dstOffset++', 'dst');
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
} else { // surrogate
if (count === 0)
throw Error("truncated utf8 surrogate");
cc = 0x10000 + (((cc & 0x3FF) << 10) | (src.charCodeAt(srcOffset++) & 0x3FF));
--count;
n += 4;
//? SET('0xF0 | (cc >> 18)', 'dstOffset++', 'dst');
//? SET('0x80 | ((cc >> 12) & 0x3F)', 'dstOffset++', 'dst');
//? SET('0x80 | ((cc >> 6) & 0x3F)', 'dstOffset++', 'dst');
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
}
} while (count > 0);
return n;
}
/**
* Decodes UTF8 bytes to a standard JavaScript string.
* @param {!ByteBuffer} src Source ByteBuffer
* @param {number} srcOffset Source offset
* @param {number} count Number of bytes to decode
* @returns {string} Decoded string
* @inner
*/
function utf8_decode(src, srcOffset, count) {
if (count === 0)
return "";
var parts = [], // readily assembled parts
batch = []; // char codes for batch processing
//? // GET(varOffset, varTarget) with varTarget referencing a ByteBuffer
while (count--) {
var c = /*? GET('srcOffset++', 'src') */,
c2, c3;
switch (c >> 4) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
batch.push(c);
break;
case 12: case 13:
if (count < 1)
throw Error("truncated utf8 sequence");
c2 = /*? GET('srcOffset++', 'src') */;
--count;
batch.push(((c & 0x1F) << 6) | (c2 & 0x3F));
break;
case 14:
if (count < 2)
throw Error("truncated utf8 sequence");
c2 = /*? GET('srcOffset++', 'src') */;
c3 = /*? GET('srcOffset++', 'src') */;
count -= 2;
batch.push(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
break;
}
if (batch.length > 1023) {
parts.push(String.fromCharCode.apply(String, batch));
batch.length = 0;
}
}
if (batch.length > 0) {
if (parts.length === 0)
return String.fromCharCode.apply(String, batch);
parts.push(String.fromCharCode.apply(String, batch));
}
return parts.join('');
}
/**
* Calculates the number of UTF8 bytes required to store a standard JavaScript string.
* @param {string} src Source string
* @param {number} srcOffset Source offset
* @param {number} count Number of char codes to calculate
* @returns {number} Number of bytes required
* @inner
*/
function utf8_calculate(src, srcOffset, count) {
if (count === 0)
return 0;
var n = 0;
do {
var cc = src.charCodeAt(srcOffset++);
--count;
if (cc < 0x80) {
n += 1;
} else if (cc < 0x800) {
n += 2;
} else if (cc < 0xD800 || cc >= 0xE000) {
n += 3;
} else {
n += 4;
}
} while (count > 0);
return n;
}
ByteBuffer.registerEncoding("utf8", utf8_encode, utf8_decode, utf8_calculate);

71
node_modules/bytebuffer/src/encodings/utf8.js generated vendored Normal file
View File

@ -0,0 +1,71 @@
//? if (UTF8) {
// utfx-embeddable
//? include("../../node_modules/utfx/dist/utfx-embeddable.js");
// encodings/utf8
/**
* Encodes this ByteBuffer's contents between {@link ByteBuffer#offset} and {@link ByteBuffer#limit} to an UTF8 encoded
* string.
* @returns {string} Hex encoded string
* @throws {RangeError} If `offset > limit`
* @expose
*/
ByteBufferPrototype.toUTF8 = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
//? if (NODE)
return this.buffer.toString("utf8", begin, end);
//? else {
var sd; try {
utfx.decodeUTF8toUTF16(function() {
//? if (DATAVIEW)
return begin < end ? this.view.getUint8(begin++) : null;
//? else
return begin < end ? this.view[begin++] : null;
}.bind(this), sd = stringDestination());
} catch (e) {
if (begin !== end)
throw RangeError("Illegal range: Truncated data, "+begin+" != "+end);
}
return sd();
//? }
};
/**
* Decodes an UTF8 encoded string to a ByteBuffer.
* @param {string} str String to decode
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer} ByteBuffer
* @expose
*/
ByteBuffer.fromUTF8 = function(str, littleEndian, noAssert) {
if (!noAssert)
if (typeof str !== 'string')
throw TypeError("Illegal str: Not a string");
//? if (NODE) {
var bb = new ByteBuffer(0, littleEndian, noAssert);
bb.buffer = new Buffer(str, "utf8");
bb.limit = bb.buffer.length;
//? } else {
var bb = new ByteBuffer(utfx.calculateUTF16asUTF8(stringSource(str), true)[1], littleEndian, noAssert),
i = 0;
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
//? if (DATAVIEW)
bb.view.setUint8(i++, b);
//? else
bb.view[i++] = b;
});
bb.limit = i;
//? }
return bb;
};
//? }

143
node_modules/bytebuffer/src/helpers.js generated vendored Normal file
View File

@ -0,0 +1,143 @@
// helpers
//? if (NODE) {
/**
* @type {!Buffer}
* @inner
*/
var EMPTY_BUFFER = new Buffer(0);
//? } else {
/**
* @type {!ArrayBuffer}
* @inner
*/
var EMPTY_BUFFER = new ArrayBuffer(0);
//? }
//? if (!INLINE) {
/**
* Asserts that a value is an integer and returns the type-safe value.
* @param {number} value Value to assert
* @param {boolean=} unsigned Whether explicitly unsigned
* @returns {number} Type-safe value
* @throws {TypeError} If `value` is not an integer
* @inner
*/
function assertInteger(value, unsigned) {
if (typeof value !== 'number' || value % 1 !== 0)
throw TypeError("Illegal value: "+offset+" (not an integer)");
return unsigned ? value >>> 0 : value | 0;
}
/**
* Asserts that a value is an integer or Long.
* @param {number|!Long} value Value to assert
* @param {boolean=} unsigned Whether explicitly unsigned
* @returns {number|!Long} Type-safe value
* @throws {TypeError} If `value` is not an integer or Long
* @inner
*/
function assertLong(value, unsigned) {
if (typeof value === 'number') {
return Long.fromNumber(value, unsigned);
} else if (typeof value === 'string') {
return Long.fromString(value, unsigned);
} else if (value && value instanceof Long) {
if (typeof unsigned !== 'undefined') {
if (unsigned && !value.unsigned) return value.toUnsigned();
if (!unsigned && value.unsigned) return value.toSigned();
}
return value;
} else
throw TypeError("Illegal value: "+value+" (not an integer or Long)");
}
/**
* Asserts that `min <= offset <= cap-size` and returns the type-safe offset.
* @param {number} offset Offset to assert
* @param {number} min Minimum offset
* @param {number} cap Cap offset
* @param {number} size Required size in bytes
* @returns {number} Type-safe offset
* @throws {TypeError} If `offset` is not an integer
* @throws {RangeError} If `offset < min || offset > cap-size`
* @inner
*/
function assertOffset(offset, min, cap, size) {
if (typeof offset !== 'number' || offset % 1 !== 0)
throw TypeError("Illegal offset: "+offset+" (not an integer)");
offset = offset | 0;
if (offset < min || offset > cap-size)
throw RangeError("Illegal offset: "+min+" <= "+value+" <= "+cap+"-"+size);
return offset;
}
/**
* assertRange return value.
* @type {Array.<number>}
*/
var rangeVal = new Array(2);
/**
* Asserts that `min <= begin <= end <= cap`. Updates `rangeVal` with the type-safe range.
* @param {number} begin Begin offset
* @param {number} end End offset
* @param {number} min Minimum offset
* @param {number} cap Cap offset
* @throws {TypeError} If `begin` or `end` is not an integer
* @throws {RangeError} If `begin < min || begin > end || end > cap`
* @inner
*/
function assertRange(begin, end, min, cap) {
if (typeof begin !== 'number' || begin % 1 !== 0)
throw TypeError("Illegal begin: "+begin+" (not a number)");
begin = begin | 0;
if (typeof end !== 'number' || end % 1 !== 0)
throw TypeError("Illegal end: "+range[1]+" (not a number)");
end = end | 0;
if (begin < min || begin > end || end > cap)
throw RangeError("Illegal range: "+min+" <= "+begin+" <= "+end+" <= "+cap);
rangeVal[0] = begin; rangeVal[1] = end;
}
//? }
//? if (BASE64 || UTF8) {
/**
* String.fromCharCode reference for compile-time renaming.
* @type {function(...number):string}
* @inner
*/
var stringFromCharCode = String.fromCharCode;
/**
* Creates a source function for a string.
* @param {string} s String to read from
* @returns {function():number|null} Source function returning the next char code respectively `null` if there are
* no more characters left.
* @throws {TypeError} If the argument is invalid
* @inner
*/
function stringSource(s) {
var i=0; return function() {
return i < s.length ? s.charCodeAt(i++) : null;
};
}
/**
* Creates a destination function for a string.
* @returns {function(number=):undefined|string} Destination function successively called with the next char code.
* Returns the final string when called without arguments.
* @inner
*/
function stringDestination() {
var cs = [], ps = []; return function() {
if (arguments.length === 0)
return ps.join('')+stringFromCharCode.apply(String, cs);
if (cs.length + arguments.length > 1024)
ps.push(stringFromCharCode.apply(String, cs)),
cs.length = 0;
Array.prototype.push.apply(cs, arguments);
};
}
//? }

222
node_modules/bytebuffer/src/macros.js generated vendored Normal file
View File

@ -0,0 +1,222 @@
//?...
// Welcome to the crazy world of MetaScript! Tell it what you need, it will not moan, and there it is.
// Substitute for the backing buffer's capacity
CAPACITY = NODE ? 'this.buffer.length' : 'this.buffer.byteLength';
// Asserts that a variable is an integer
ASSERT_INTEGER = function(varValue, unsigned) {
if (VERBOSE_MS) writeln(__+'// <ASSERT_INTEGER>');
if (INLINE) {
writeln(__+'if (typeof '+varValue+' !== \'number\' || '+varValue+' % 1 !== 0)');
writeln(__+' throw TypeError("Illegal '+varValue+': "+'+varValue+'+" (not an integer)");');
writeln(__+varValue+' '+(unsigned ? '>>>' : '|')+'= 0;');
} else {
writeln(__+varValue+' = assertInteger('+varValue+(typeof unsigned !== 'undefined' ? ', '+unsigned : '')+');');
}
if (VERBOSE_MS) writeln(__+'// </ASSERT_INTEGER>');
};
// Asserts that a variable is a number or Long
ASSERT_LONG = function(varValue, unsigned) {
if (typeof varValue === 'undefined') varValue = 'value';
if (VERBOSE_MS) writeln(__+'// <ASSERT_LONG>');
if (INLINE) {
writeln(__+'if (typeof '+varValue+' === \'number\')');
writeln(__+' '+varValue+' = Long.fromNumber('+varValue+');');
writeln(__+'else if (typeof '+varValue+' === \'string\')');
writeln(__+' '+varValue+' = Long.fromString('+varValue+');');
if (typeof unsigned !== 'undefined') { // When explicitly specified only
writeln(__+'else if ('+varValue+' && '+varValue+' instanceof Long)');
if (unsigned) {
writeln(__+' if (!'+varValue+'.unsigned) '+varValue+' = '+varValue+'.toUnsigned();');
} else {
writeln(__+' if ('+varValue+'.unsigned) '+varValue+' = '+varValue+'.toSigned();');
}
writeln(__+'else');
} else {
writeln(__+'else if (!('+varValue+' && '+varValue+' instanceof Long))');
}
writeln(__+' throw TypeError("Illegal '+varValue+': "+'+varValue+'+" (not an integer or Long)");');
} else {
writeln(__+varValue+' = assertLong('+varValue+(typeof unsigned !== 'undefined' ? ', '+unsigned : '')+');');
}
if (VERBOSE_MS) writeln(__+'// </ASSERT_LONG>');
};
// Casts a variable to a Long if necessary
LONG = function(varValue, unsigned) {
if (typeof varValue === 'undefined') varValue = 'value';
if (VERBOSE_MS) writeln(__+'// <LONG'+(typeof unsigned === 'boolean' ? ' unsigned='+unsigned : '')+'>');
writeln(__+'if (typeof '+varValue+' === \'number\')');
writeln(__+' '+varValue+' = Long.fromNumber('+varValue+(typeof unsigned === 'boolean' ? ', '+unsigned : '')+');');
writeln(__+'else if (typeof '+varValue+' === \'string\')');
writeln(__+' '+varValue+' = Long.fromString('+varValue+(typeof unsigned === 'boolean' ? ', '+unsigned : '')+');');
if (typeof unsigned === 'boolean') {
writeln(__+'else if ('+varValue+'.unsigned !== '+unsigned+') '+varValue+' = '+varValue+'.'+(unsigned ? 'toUnsigned' : 'toSigned')+'();');
}
if (VERBOSE_MS) writeln(__+'// </LONG>');
};
// Asserts that an offset is valid
ASSERT_OFFSET = function(size, varOffset) {
if (typeof size === 'undefined') size = 0;
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (VERBOSE_MS) writeln(__+'// <ASSERT_OFFSET>');
if (INLINE) {
writeln(__+'if (typeof '+varOffset+' !== \'number\' || '+varOffset+' % 1 !== 0)');
writeln(__+' throw TypeError("Illegal '+varOffset+': "+'+varOffset+'+" (not an integer)");');
writeln(__+varOffset+' >>>= 0;');
writeln(__+'if ('+varOffset+' < 0 || '+varOffset+' + '+size+' > '+CAPACITY+')');
writeln(__+' throw RangeError("Illegal '+varOffset+': 0 <= "+'+varOffset+'+" (+"+'+size+'+") <= "+'+CAPACITY+');');
} else {
writeln(__+varOffset+' = assertOffset('+varOffset+', 0, '+CAPACITY+', '+size+');');
}
if (VERBOSE_MS) writeln(__+'// </ASSERT_OFFSET>');
};
// Asserts that a range is valid
ASSERT_RANGE = function(varBegin, varEnd) {
if (typeof varBegin === 'undefined') varBegin = 'begin';
if (typeof varEnd === 'undefined') varEnd = 'end';
if (VERBOSE_MS) writeln(__+'// <ASSERT_RANGE>');
if (INLINE) {
writeln(__+'if (typeof '+varBegin+' !== \'number\' || '+varBegin+' % 1 !== 0)');
writeln(__+' throw TypeError("Illegal '+varBegin+': Not an integer");');
writeln(__+varBegin+' >>>= 0;');
writeln(__+'if (typeof '+varEnd+' !== \'number\' || '+varEnd+' % 1 !== 0)');
writeln(__+' throw TypeError("Illegal '+varEnd+': Not an integer");');
writeln(__+varEnd+' >>>= 0;');
writeln(__+'if ('+varBegin+' < 0 || '+varBegin+' > '+varEnd+' || '+varEnd+' > '+CAPACITY+')');
writeln(__+' throw RangeError("Illegal range: 0 <= "+'+varBegin+'+" <= "+'+varEnd+'+" <= "+'+CAPACITY+');');
} else {
writeln(__+'assertRange('+varBegin+', '+varEnd+', 0, '+CAPACITY+');');
writeln(__+varBegin+' = rangeVal[0]; '+varEnd+' = rangeVal[1];');
}
if (VERBOSE_MS) writeln(__+'// </ASSERT_RANGE>');
};
// ENSURE_CAPACITY counter in case that multiple calls are used in a single method
var ECN = 0;
// Ensures that a ByteBuffer is backed by a buffer that takes `size` additional capacity
ENSURE_CAPACITY = function(size, varOffset) {
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (VERBOSE_MS) writeln(__+'// <ENSURE_CAPACITY size='+size+'>');
if (INLINE) {
writeln(__+varOffset+' += '+size+';');
writeln(__+'var capacity'+ECN+' = '+CAPACITY+';');
writeln(__+'if ('+varOffset+' > capacity'+ECN+')');
writeln(__+' this.resize((capacity'+ECN+' *= 2) > '+varOffset+' ? capacity'+ECN+' : '+varOffset+');');
writeln(__+varOffset+' -= '+size+';');
} else {
writeln(__+'this.ensureCapacity('+varOffset+'+'+size+');');
}
if (VERBOSE_MS) writeln(__+'// </ENSURE_CAPACITY>');
++ECN;
};
// Sets up a relative operation if `size` is omitted, else increases offset by `size`
RELATIVE = function(size, varOffset, varRelOffset) {
if (VERBOSE_MS) writeln(__+'// <RELATIVE'+(typeof size !== 'undefined' ? ' size='+size : '')+'>');
if (typeof size === 'undefined') {
if (typeof varOffset === 'undefined') varOffset = "offset";
if (typeof varRelOffset === 'undefined') varRelOffset = "this.offset";
writeln(__+'var relative = typeof '+varOffset+' === \'undefined\';');
writeln(__+'if (relative) '+varOffset+' = '+varRelOffset+';');
} else {
if (typeof varOffset === 'undefined') varOffset = "this.offset";
writeln(__+'if (relative) this.offset += '+size+';');
}
if (VERBOSE_MS) writeln(__+'// </RELATIVE>');
};
// Reads an uint32 from an array
READ_UINT32_ARRAY = function(varValue, varOffset, varTarget, varEndian) {
if (typeof varValue === 'undefined') varValue = 'value';
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (typeof varTarget === 'undefined') varTarget = NODE ? 'this.buffer' : 'this.view';
var ____ = typeof varEndian !== 'boolean' ? ' ' : '';
if (VERBOSE_MS) writeln(__+'// <READ_UINT32'+(typeof varEndian === 'boolean' ? ' le='+varEndian : '')+'>');
if (NODE || !DATAVIEW) {
if (typeof varEndian !== 'boolean')
writeln(__+'if ('+(varEndian || 'this.littleEndian')+') {');
if (typeof varEndian !== 'boolean' || varEndian === true) {
writeln(__+____+varValue+' = '+varTarget+'['+varOffset+'+2] << 16;');
writeln(__+____+varValue+' |= '+varTarget+'['+varOffset+'+1] << 8;');
writeln(__+____+varValue+' |= '+varTarget+'['+varOffset+' ];');
writeln(__+____+varValue+' += '+varTarget+'['+varOffset+'+3] << 24 >>> 0;');
}
if (typeof varEndian !== 'boolean')
writeln(__+'} else {');
if (typeof varEndian !== 'boolean' || varEndian === false) {
writeln(__+____+varValue+' = '+varTarget+'['+varOffset+'+1] << 16;');
writeln(__+____+varValue+' |= '+varTarget+'['+varOffset+'+2] << 8;');
writeln(__+____+varValue+' |= '+varTarget+'['+varOffset+'+3];');
writeln(__+____+varValue+' += '+varTarget+'['+varOffset+' ] << 24 >>> 0;');
}
if (typeof varEndian !== 'boolean')
writeln(__+'}');
} else {
writeln(__+varTarget+'.getUint32('+varOffset+', '+varEndian+');');
}
if (VERBOSE_MS) writeln(__+'// </READ_UINT32>');
};
// Writes an uint32 to an array
WRITE_UINT32_ARRAY = function(varValue, varOffset, varTarget, varEndian) {
if (typeof varValue === 'undefined') varValue = 'value';
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (typeof varTarget === 'undefined') varTarget = NODE ? 'this.buffer' : 'this.view';
var ____ = typeof varEndian !== 'boolean' ? ' ' : '';
if (VERBOSE_MS) writeln(__+'// <WRITE_UINT32'+(typeof varEndian === 'boolean' ? ' le='+varEndian : '')+'>');
if (NODE || !DATAVIEW) {
if (typeof varEndian !== 'boolean')
writeln(__+'if ('+(varEndian || 'this.littleEndian')+') {');
if (typeof varEndian !== 'boolean' || varEndian === true) {
writeln(__+____+varTarget+'['+varOffset+'+3] = ('+varValue+' >>> 24) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+'+2] = ('+varValue+' >>> 16) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+'+1] = ('+varValue+' >>> 8) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+' ] = '+varValue+' & 0xFF;');
}
if (typeof varEndian !== 'boolean')
writeln(__+'} else {');
if (typeof varEndian !== 'boolean' || varEndian === false) {
writeln(__+____+varTarget+'['+varOffset+' ] = ('+varValue+' >>> 24) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+'+1] = ('+varValue+' >>> 16) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+'+2] = ('+varValue+' >>> 8) & 0xFF;');
writeln(__+____+varTarget+'['+varOffset+'+3] = '+varValue+' & 0xFF;');
}
if (typeof varEndian !== 'boolean')
writeln(__+'}');
} else {
writeln(__+varTarget+'.setUint32('+varValue+', '+varOffset+', '+varEndian+');');
}
if (VERBOSE_MS) writeln(__+'// </WRITE_UINT32>');
};
SET = function(varValue, varOffset, varTarget) { // with varTarget referencing a ByteBuffer
if (typeof varValue === 'undefined') varValue = 'value';
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (typeof varTarget === 'undefined') varTarget = 'this';
if (NODE) {
writeln(__+varTarget+'.buffer['+varOffset+'] = '+varValue+';');
} else if (DATAVIEW) {
writeln(__+varTarget+'.view.setUint8('+varValue+', '+varOffset+');');
} else {
writeln(__+varTarget+'.view['+varOffset+'] = '+varValue+';');
}
};
GET = function(varOffset, varTarget) { // with varTarget referencing a ByteBuffer
if (typeof varOffset === 'undefined') varOffset = 'offset';
if (typeof varTarget === 'undefined') varTarget = 'this';
if (NODE) {
write(varTarget+'.buffer['+varOffset+']');
} else if (DATAVIEW) {
write(varTarget+'.view.getUint8('+varOffset+')');
} else {
write(varTarget+'.view['+varOffset+']');
}
};
//?.

58
node_modules/bytebuffer/src/methods/append.js generated vendored Normal file
View File

@ -0,0 +1,58 @@
/**
* Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended
* data's length.
//? if (NODE) {
* @param {!ByteBuffer|!Buffer|!ArrayBuffer|!Uint8Array|string} source Data to append. If `source` is a ByteBuffer, its
* offsets will be modified according to the performed read operation.
//? } else {
* @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to append. If `source` is a ByteBuffer, its offsets
* will be modified according to the performed read operation.
//? }
* @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
* @param {number=} offset Offset to append at. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer} this
* @expose
* @example A relative `<01 02>03.append(<04 05>)` will result in `<01 02 04 05>, 04 05|`
* @example An absolute `<01 02>03.append(04 05>, 1)` will result in `<01 04>05, 04 05|`
*/
ByteBufferPrototype.append = function(source, encoding, offset) {
if (typeof encoding === 'number' || typeof encoding !== 'string') {
offset = encoding;
encoding = undefined;
}
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET();
}
if (!(source instanceof ByteBuffer))
source = ByteBuffer.wrap(source, encoding);
var length = source.limit - source.offset;
if (length <= 0) return this; // Nothing to append
//? ENSURE_CAPACITY('length');
//? if (NODE)
source.buffer.copy(this.buffer, offset, source.offset, source.limit);
//? else if (DATAVIEW)
new Uint8Array(this.buffer, offset).set(new Uint8Array(source.buffer).subarray(source.offset, source.limit));
//? else
this.view.set(source.view.subarray(source.offset, source.limit), offset);
source.offset += length;
//? RELATIVE('length');
return this;
};
/**
* Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents at and after the
specified offset up to the length of this ByteBuffer's data.
* @param {!ByteBuffer} target Target ByteBuffer
* @param {number=} offset Offset to append to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {!ByteBuffer} this
* @expose
* @see ByteBuffer#append
*/
ByteBufferPrototype.appendTo = function(target, offset) {
target.append(this, offset);
return this;
};

12
node_modules/bytebuffer/src/methods/assert.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
/**
* Enables or disables assertions of argument types and offsets. Assertions are enabled by default but you can opt to
* disable them if your code already makes sure that everything is valid.
* @param {boolean} assert `true` to enable assertions, otherwise `false`
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.assert = function(assert) {
this.noAssert = !assert;
return this;
};

8
node_modules/bytebuffer/src/methods/capacity.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
/**
* Gets the capacity of this ByteBuffer's backing buffer.
* @returns {number} Capacity of the backing buffer
* @expose
*/
ByteBufferPrototype.capacity = function() {
return /*?= CAPACITY */;
};

13
node_modules/bytebuffer/src/methods/clear.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Clears this ByteBuffer's offsets by setting {@link ByteBuffer#offset} to `0` and {@link ByteBuffer#limit} to the
* backing buffer's capacity. Discards {@link ByteBuffer#markedOffset}.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.clear = function() {
this.offset = 0;
this.limit = /*?= CAPACITY */;
this.markedOffset = -1;
return this;
};

34
node_modules/bytebuffer/src/methods/clone.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* Creates a cloned instance of this ByteBuffer, preset with this ByteBuffer's values for {@link ByteBuffer#offset},
* {@link ByteBuffer#markedOffset} and {@link ByteBuffer#limit}.
* @param {boolean=} copy Whether to copy the backing buffer or to return another view on the same, defaults to `false`
* @returns {!ByteBuffer} Cloned instance
* @expose
*/
ByteBufferPrototype.clone = function(copy) {
var bb = new ByteBuffer(0, this.littleEndian, this.noAssert);
if (copy) {
//? if (NODE) {
var buffer = new Buffer(this.buffer.length);
this.buffer.copy(buffer);
bb.buffer = buffer;
//? } else {
bb.buffer = new ArrayBuffer(this.buffer.byteLength);
//? if (DATAVIEW) {
new Uint8Array(bb.buffer).set(this.buffer);
bb.view = new DataView(bb.buffer);
//? } else {
bb.view = new Uint8Array(bb.buffer);
//? }
//? }
} else {
bb.buffer = this.buffer;
//? if (!NODE)
bb.view = this.view;
}
bb.offset = this.offset;
bb.markedOffset = this.markedOffset;
bb.limit = this.limit;
return bb;
};

49
node_modules/bytebuffer/src/methods/compact.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
/**
* Compacts this ByteBuffer to be backed by a {@link ByteBuffer#buffer} of its contents' length. Contents are the bytes
* between {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. Will set `offset = 0` and `limit = capacity` and
* adapt {@link ByteBuffer#markedOffset} to the same relative position if set.
* @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}
* @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.compact = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
if (begin === 0 && end === /*?= CAPACITY */)
return this; // Already compacted
var len = end - begin;
if (len === 0) {
this.buffer = EMPTY_BUFFER;
//? if (!NODE)
this.view = null;
if (this.markedOffset >= 0) this.markedOffset -= begin;
this.offset = 0;
this.limit = 0;
return this;
}
//? if (NODE) {
var buffer = new Buffer(len);
this.buffer.copy(buffer, 0, begin, end);
this.buffer = buffer;
//? } else if (DATAVIEW) {
var buffer = new ArrayBuffer(len);
new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(begin, end));
this.buffer = buffer;
this.view = new DataView(buffer);
//? } else {
var buffer = new ArrayBuffer(len);
var view = new Uint8Array(buffer);
view.set(this.view.subarray(begin, end));
this.buffer = buffer;
this.view = view;
//? }
if (this.markedOffset >= 0) this.markedOffset -= begin;
this.offset = 0;
this.limit = len;
return this;
};

73
node_modules/bytebuffer/src/methods/copy.js generated vendored Normal file
View File

@ -0,0 +1,73 @@
/**
* Creates a copy of this ByteBuffer's contents. Contents are the bytes between {@link ByteBuffer#offset} and
* {@link ByteBuffer#limit}.
* @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.
* @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
* @returns {!ByteBuffer} Copy
* @expose
*/
ByteBufferPrototype.copy = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
if (begin === end)
return new ByteBuffer(0, this.littleEndian, this.noAssert);
var capacity = end - begin,
bb = new ByteBuffer(capacity, this.littleEndian, this.noAssert);
bb.offset = 0;
bb.limit = capacity;
if (bb.markedOffset >= 0) bb.markedOffset -= begin;
this.copyTo(bb, 0, begin, end);
return bb;
};
/**
* Copies this ByteBuffer's contents to another ByteBuffer. Contents are the bytes between {@link ByteBuffer#offset} and
* {@link ByteBuffer#limit}.
* @param {!ByteBuffer} target Target ByteBuffer
* @param {number=} targetOffset Offset to copy to. Will use and increase the target's {@link ByteBuffer#offset}
* by the number of bytes copied if omitted.
* @param {number=} sourceOffset Offset to start copying from. Will use and increase {@link ByteBuffer#offset} by the
* number of bytes copied if omitted.
* @param {number=} sourceLimit Offset to end copying from, defaults to {@link ByteBuffer#limit}
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.copyTo = function(target, targetOffset, sourceOffset, sourceLimit) {
var relative,
targetRelative;
if (!this.noAssert) {
if (!ByteBuffer.isByteBuffer(target))
throw TypeError("Illegal target: Not a ByteBuffer");
}
targetOffset = (targetRelative = typeof targetOffset === 'undefined') ? target.offset : targetOffset | 0;
sourceOffset = (relative = typeof sourceOffset === 'undefined') ? this.offset : sourceOffset | 0;
sourceLimit = typeof sourceLimit === 'undefined' ? this.limit : sourceLimit | 0;
//? var TARGET_CAPACITY = NODE ? 'target.buffer.length' : 'target.buffer.byteLength';
if (targetOffset < 0 || targetOffset > /*?= TARGET_CAPACITY */)
throw RangeError("Illegal target range: 0 <= "+targetOffset+" <= "+/*?= TARGET_CAPACITY */);
if (sourceOffset < 0 || sourceLimit > /*?= CAPACITY */)
throw RangeError("Illegal source range: 0 <= "+sourceOffset+" <= "+/*?= CAPACITY */);
var len = sourceLimit - sourceOffset;
if (len === 0)
return target; // Nothing to copy
target.ensureCapacity(targetOffset + len);
//? if (NODE)
this.buffer.copy(target.buffer, targetOffset, sourceOffset, sourceLimit);
//? else if (DATAVIEW)
new Uint8Array(target.buffer).set(new Uint8Array(this.buffer).subarray(sourceOffset, sourceLimit), targetOffset);
//? else
target.view.set(this.view.subarray(sourceOffset, sourceLimit), targetOffset);
if (relative) this.offset += len;
if (targetRelative) target.offset += len;
return this;
};

15
node_modules/bytebuffer/src/methods/ensureCapacity.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
/**
* Makes sure that this ByteBuffer is backed by a {@link ByteBuffer#buffer} of at least the specified capacity. If the
* current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity,
* the required capacity will be used instead.
* @param {number} capacity Required capacity
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.ensureCapacity = function(capacity) {
var current = /*?= CAPACITY */;
if (current < capacity)
return this.resize((current *= 2) > capacity ? current : capacity);
return this;
};

35
node_modules/bytebuffer/src/methods/fill.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
/**
* Overwrites this ByteBuffer's contents with the specified value. Contents are the bytes between
* {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.
* @param {number|string} value Byte value to fill with. If given as a string, the first character is used.
* @param {number=} begin Begin offset. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted. defaults to {@link ByteBuffer#offset}.
* @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
* @returns {!ByteBuffer} this
* @expose
* @example `someByteBuffer.clear().fill(0)` fills the entire backing buffer with zeroes
*/
ByteBufferPrototype.fill = function(value, begin, end) {
//? RELATIVE(undefined, 'begin');
if (typeof value === 'string' && value.length > 0)
value = value.charCodeAt(0);
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_INTEGER('value');
//? ASSERT_RANGE();
}
if (begin >= end)
return this; // Nothing to fill
//? if (NODE) {
this.buffer.fill(value, begin, end);
begin = end;
//? } else if (DATAVIEW) {
while (begin < end) this.view.setUint8(begin++, value);
//? } else {
while (begin < end) this.view[begin++] = value;
//? }
if (relative) this.offset = begin;
return this;
};

11
node_modules/bytebuffer/src/methods/flip.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets `limit = offset` and
* `offset = 0`. Make sure always to flip a ByteBuffer when all relative read or write operations are complete.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.flip = function() {
this.limit = this.offset;
this.offset = 0;
return this;
};

17
node_modules/bytebuffer/src/methods/mark.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* Marks an offset on this ByteBuffer to be used later.
* @param {number=} offset Offset to mark. Defaults to {@link ByteBuffer#offset}.
* @returns {!ByteBuffer} this
* @throws {TypeError} If `offset` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @see ByteBuffer#reset
* @expose
*/
ByteBufferPrototype.mark = function(offset) {
offset = typeof offset === 'undefined' ? this.offset : offset;
if (!this.noAssert) {
//? ASSERT_OFFSET();
}
this.markedOffset = offset;
return this;
};

36
node_modules/bytebuffer/src/methods/order.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* Sets the byte order.
* @param {boolean} littleEndian `true` for little endian byte order, `false` for big endian
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.order = function(littleEndian) {
if (!this.noAssert) {
if (typeof littleEndian !== 'boolean')
throw TypeError("Illegal littleEndian: Not a boolean");
}
this.littleEndian = !!littleEndian;
return this;
};
/**
* Switches (to) little endian byte order.
* @param {boolean=} littleEndian Defaults to `true`, otherwise uses big endian
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.LE = function(littleEndian) {
this.littleEndian = typeof littleEndian !== 'undefined' ? !!littleEndian : true;
return this;
};
/**
* Switches (to) big endian byte order.
* @param {boolean=} bigEndian Defaults to `true`, otherwise uses little endian
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.BE = function(bigEndian) {
this.littleEndian = typeof bigEndian !== 'undefined' ? !bigEndian : false;
return this;
};

87
node_modules/bytebuffer/src/methods/prepend.js generated vendored Normal file
View File

@ -0,0 +1,87 @@
/**
* Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the
* prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer
* will be resized and its contents moved accordingly.
//? if (NODE) {
* @param {!ByteBuffer|string||!Buffer} source Data to prepend. If `source` is a ByteBuffer, its offset will be modified
* according to the performed read operation.
//? } else {
* @param {!ByteBuffer|string|!ArrayBuffer} source Data to prepend. If `source` is a ByteBuffer, its offset will be
* modified according to the performed read operation.
//? }
* @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
* @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes
* prepended if omitted.
* @returns {!ByteBuffer} this
* @expose
* @example A relative `00<01 02 03>.prepend(<04 05>)` results in `<04 05 01 02 03>, 04 05|`
* @example An absolute `00<01 02 03>.prepend(<04 05>, 2)` results in `04<05 02 03>, 04 05|`
*/
ByteBufferPrototype.prepend = function(source, encoding, offset) {
if (typeof encoding === 'number' || typeof encoding !== 'string') {
offset = encoding;
encoding = undefined;
}
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET();
}
if (!(source instanceof ByteBuffer))
source = ByteBuffer.wrap(source, encoding);
var len = source.limit - source.offset;
if (len <= 0) return this; // Nothing to prepend
var diff = len - offset;
if (diff > 0) { // Not enough space before offset, so resize + move
//? if (NODE) {
var buffer = new Buffer(this.buffer.length + diff);
this.buffer.copy(buffer, len, offset, this.buffer.length);
this.buffer = buffer;
//? } else if (DATAVIEW) {
var buffer = new ArrayBuffer(this.buffer.byteLength + diff);
var arrayView = new Uint8Array(buffer);
arrayView.set(new Uint8Array(this.buffer).subarray(offset, this.buffer.byteLength), len);
this.buffer = buffer;
this.view = new DataView(buffer);
//? } else {
var buffer = new ArrayBuffer(this.buffer.byteLength + diff);
var view = new Uint8Array(buffer);
view.set(this.view.subarray(offset, this.buffer.byteLength), len);
this.buffer = buffer;
this.view = view;
//? }
this.offset += diff;
if (this.markedOffset >= 0) this.markedOffset += diff;
this.limit += diff;
offset += diff;
}/*? if (!NODE) { */ else {
var arrayView = new Uint8Array(this.buffer);
}
//? }
//? if (NODE)
source.buffer.copy(this.buffer, offset - len, source.offset, source.limit);
//? else if (DATAVIEW)
arrayView.set(new Uint8Array(source.buffer).subarray(source.offset, source.limit), offset - len);
//? else
this.view.set(source.view.subarray(source.offset, source.limit), offset - len);
source.offset = source.limit;
if (relative)
this.offset -= len;
return this;
};
/**
* Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the
* prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer
* will be resized and its contents moved accordingly.
* @param {!ByteBuffer} target Target ByteBuffer
* @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes
* prepended if omitted.
* @returns {!ByteBuffer} this
* @expose
* @see ByteBuffer#prepend
*/
ByteBufferPrototype.prependTo = function(target, offset) {
target.prepend(this, offset);
return this;
};

16
node_modules/bytebuffer/src/methods/printDebug.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
//? if (DEBUG) {
/**
* Prints debug information about this ByteBuffer's contents.
* @param {function(string)=} out Output function to call, defaults to console.log
* @expose
*/
ByteBufferPrototype.printDebug = function(out) {
if (typeof out !== 'function') out = console.log.bind(console);
out(
this.toString()+"\n"+
"-------------------------------------------------------------------\n"+
this.toDebug(/* columns */ true)
);
};
//? }

9
node_modules/bytebuffer/src/methods/remaining.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
* Gets the number of remaining readable bytes. Contents are the bytes between {@link ByteBuffer#offset} and
* {@link ByteBuffer#limit}, so this returns `limit - offset`.
* @returns {number} Remaining readable bytes. May be negative if `offset > limit`.
* @expose
*/
ByteBufferPrototype.remaining = function() {
return this.limit - this.offset;
};

17
node_modules/bytebuffer/src/methods/reset.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
/**
* Resets this ByteBuffer's {@link ByteBuffer#offset}. If an offset has been marked through {@link ByteBuffer#mark}
* before, `offset` will be set to {@link ByteBuffer#markedOffset}, which will then be discarded. If no offset has been
* marked, sets `offset = 0`.
* @returns {!ByteBuffer} this
* @see ByteBuffer#mark
* @expose
*/
ByteBufferPrototype.reset = function() {
if (this.markedOffset >= 0) {
this.offset = this.markedOffset;
this.markedOffset = -1;
} else {
this.offset = 0;
}
return this;
};

39
node_modules/bytebuffer/src/methods/resize.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
/**
* Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that
* large or larger.
* @param {number} capacity Capacity required
* @returns {!ByteBuffer} this
* @throws {TypeError} If `capacity` is not a number
* @throws {RangeError} If `capacity < 0`
* @expose
*/
ByteBufferPrototype.resize = function(capacity) {
if (!this.noAssert) {
//? ASSERT_INTEGER('capacity');
if (capacity < 0)
throw RangeError("Illegal capacity: 0 <= "+capacity);
}
//? if (NODE) {
if (this.buffer.length < capacity) {
var buffer = new Buffer(capacity);
this.buffer.copy(buffer);
this.buffer = buffer;
}
//? } else {
if (this.buffer.byteLength < capacity) {
//? if (DATAVIEW) {
var buffer = new ArrayBuffer(capacity);
new Uint8Array(buffer).set(new Uint8Array(this.buffer));
this.buffer = buffer;
this.view = new DataView(buffer);
//? } else {
var buffer = new ArrayBuffer(capacity);
var view = new Uint8Array(buffer);
view.set(this.view);
this.buffer = buffer;
this.view = view;
//? }
}
//? }
return this;
};

25
node_modules/bytebuffer/src/methods/reverse.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
/**
* Reverses this ByteBuffer's contents.
* @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}
* @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.reverse = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
if (begin === end)
return this; // Nothing to reverse
//? if (NODE)
Array.prototype.reverse.call(this.buffer.slice(begin, end));
//? else if (DATAVIEW) {
Array.prototype.reverse.call(new Uint8Array(this.buffer).subarray(begin, end));
this.view = new DataView(this.buffer); // FIXME: Why exactly is this necessary?
//? } else {
Array.prototype.reverse.call(this.view.subarray(begin, end));
//? }
return this;
};

19
node_modules/bytebuffer/src/methods/skip.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Skips the next `length` bytes. This will just advance
* @param {number} length Number of bytes to skip. May also be negative to move the offset back.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.skip = function(length) {
if (!this.noAssert) {
//? ASSERT_INTEGER('length');
}
var offset = this.offset + length;
if (!this.noAssert) {
if (offset < 0 || offset > /*?= CAPACITY */)
throw RangeError("Illegal length: 0 <= "+this.offset+" + "+length+" <= "+/*?= CAPACITY */);
}
this.offset = offset;
return this;
};

18
node_modules/bytebuffer/src/methods/slice.js generated vendored Normal file
View File

@ -0,0 +1,18 @@
/**
* Slices this ByteBuffer by creating a cloned instance with `offset = begin` and `limit = end`.
* @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.
* @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
* @returns {!ByteBuffer} Clone of this ByteBuffer with slicing applied, backed by the same {@link ByteBuffer#buffer}
* @expose
*/
ByteBufferPrototype.slice = function(begin, end) {
if (typeof begin === 'undefined') begin = this.offset;
if (typeof end === 'undefined') end = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE();
}
var bb = this.clone();
bb.offset = begin;
bb.limit = end;
return bb;
};

13
node_modules/bytebuffer/src/methods/static/accessor.js generated vendored Normal file
View File

@ -0,0 +1,13 @@
/**
* Gets the accessor type.
* @returns {Function} `Buffer` under node.js, `Uint8Array` respectively `DataView` in the browser (classes)
* @expose
*/
ByteBuffer.accessor = function() {
//? if (NODE)
return Buffer;
//? else if (DATAVIEW)
return DataView;
//? else
return Uint8Array;
};

14
node_modules/bytebuffer/src/methods/static/allocate.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
/**
* Allocates a new ByteBuffer backed by a buffer of the specified capacity.
* @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer}
* @expose
*/
ByteBuffer.allocate = function(capacity, littleEndian, noAssert) {
return new ByteBuffer(capacity, littleEndian, noAssert);
};

55
node_modules/bytebuffer/src/methods/static/concat.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
/**
* Concatenates multiple ByteBuffers into one.
//? if (NODE) {
* @param {!Array.<!ByteBuffer|!Buffer|!ArrayBuffer|!Uint8Array|string>} buffers Buffers to concatenate
//? } else {
* @param {!Array.<!ByteBuffer|!ArrayBuffer|!Uint8Array|string>} buffers Buffers to concatenate
//? }
* @param {(string|boolean)=} encoding String encoding if `buffers` contains a string ("base64", "hex", "binary",
* defaults to "utf8")
* @param {boolean=} littleEndian Whether to use little or big endian byte order for the resulting ByteBuffer. Defaults
* to {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values for the resulting ByteBuffer. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer} Concatenated ByteBuffer
* @expose
*/
ByteBuffer.concat = function(buffers, encoding, littleEndian, noAssert) {
if (typeof encoding === 'boolean' || typeof encoding !== 'string') {
noAssert = littleEndian;
littleEndian = encoding;
encoding = undefined;
}
var capacity = 0;
for (var i=0, k=buffers.length, length; i<k; ++i) {
if (!ByteBuffer.isByteBuffer(buffers[i]))
buffers[i] = ByteBuffer.wrap(buffers[i], encoding);
length = buffers[i].limit - buffers[i].offset;
if (length > 0) capacity += length;
}
if (capacity === 0)
return new ByteBuffer(0, littleEndian, noAssert);
var bb = new ByteBuffer(capacity, littleEndian, noAssert),
bi;
//? if (!NODE && DATAVIEW)
var view = new Uint8Array(bb.buffer);
i=0; while (i<k) {
bi = buffers[i++];
length = bi.limit - bi.offset;
if (length <= 0) continue;
//? if (NODE) {
bi.buffer.copy(bb.buffer, bb.offset, bi.offset, bi.limit);
bb.offset += length;
//? } else {
//? if (DATAVIEW)
view.set(new Uint8Array(bi.buffer).subarray(bi.offset, bi.limit), bb.offset);
//? else
bb.view.set(bi.view.subarray(bi.offset, bi.limit), bb.offset);
bb.offset += length;
//? }
}
bb.limit = bb.offset;
bb.offset = 0;
return bb;
};

View File

@ -0,0 +1,9 @@
/**
* Tests if the specified type is a ByteBuffer.
* @param {*} bb ByteBuffer to test
* @returns {boolean} `true` if it is a ByteBuffer, otherwise `false`
* @expose
*/
ByteBuffer.isByteBuffer = function(bb) {
return (bb && bb["__isByteBuffer__"]) === true;
};

11
node_modules/bytebuffer/src/methods/static/type.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
* Gets the backing buffer type.
* @returns {Function} `Buffer` under node.js, `ArrayBuffer` in the browser (classes)
* @expose
*/
ByteBuffer.type = function() {
//? if (NODE)
return Buffer;
//? else
return ArrayBuffer;
};

125
node_modules/bytebuffer/src/methods/static/wrap.js generated vendored Normal file
View File

@ -0,0 +1,125 @@
/**
* Wraps a buffer or a string. Sets the allocated ByteBuffer's {@link ByteBuffer#offset} to `0` and its
* {@link ByteBuffer#limit} to the length of the wrapped data.
//? if (NODE) {
* @param {!ByteBuffer|!Buffer|!ArrayBuffer|!Uint8Array|string|!Array.<number>} buffer Anything that can be wrapped
//? } else {
* @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string|!Array.<number>} buffer Anything that can be wrapped
//? }
* @param {(string|boolean)=} encoding String encoding if `buffer` is a string ("base64", "hex", "binary", defaults to
* "utf8")
* @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
* {@link ByteBuffer.DEFAULT_ENDIAN}.
* @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
* {@link ByteBuffer.DEFAULT_NOASSERT}.
* @returns {!ByteBuffer} A ByteBuffer wrapping `buffer`
* @expose
*/
ByteBuffer.wrap = function(buffer, encoding, littleEndian, noAssert) {
if (typeof encoding !== 'string') {
noAssert = littleEndian;
littleEndian = encoding;
encoding = undefined;
}
if (typeof buffer === 'string') {
if (typeof encoding === 'undefined')
encoding = "utf8";
switch (encoding) {
//? if (BASE64) {
case "base64":
return ByteBuffer.fromBase64(buffer, littleEndian);
//? } if (HEX) {
case "hex":
return ByteBuffer.fromHex(buffer, littleEndian);
//? } if (BINARY) {
case "binary":
return ByteBuffer.fromBinary(buffer, littleEndian);
//? } if (UTF8) {
case "utf8":
return ByteBuffer.fromUTF8(buffer, littleEndian);
//? } if (DEBUG) {
case "debug":
return ByteBuffer.fromDebug(buffer, littleEndian);
//? }
default:
throw Error("Unsupported encoding: "+encoding);
}
}
if (buffer === null || typeof buffer !== 'object')
throw TypeError("Illegal buffer");
var bb;
if (ByteBuffer.isByteBuffer(buffer)) {
bb = ByteBufferPrototype.clone.call(buffer);
bb.markedOffset = -1;
return bb;
}
//? if (NODE) {
var i = 0,
k = 0,
b;
if (buffer instanceof Uint8Array) { // Extract bytes from Uint8Array
b = new Buffer(buffer.length);
if (memcpy) { // Fast
memcpy(b, 0, buffer.buffer, buffer.byteOffset, buffer.byteOffset + buffer.length);
} else { // Slow
for (i=0, k=buffer.length; i<k; ++i)
b[i] = buffer[i];
}
buffer = b;
} else if (buffer instanceof ArrayBuffer) { // Convert ArrayBuffer to Buffer
b = new Buffer(buffer.byteLength);
if (memcpy) { // Fast
memcpy(b, 0, buffer, 0, buffer.byteLength);
} else { // Slow
buffer = new Uint8Array(buffer);
for (i=0, k=buffer.length; i<k; ++i) {
b[i] = buffer[i];
}
}
buffer = b;
} else if (!(buffer instanceof Buffer)) { // Create from octets if it is an error, otherwise fail
if (Object.prototype.toString.call(buffer) !== "[object Array]")
throw TypeError("Illegal buffer");
buffer = new Buffer(buffer);
}
bb = new ByteBuffer(0, littleEndian, noAssert);
if (buffer.length > 0) { // Avoid references to more than one EMPTY_BUFFER
bb.buffer = buffer;
bb.limit = buffer.length;
}
//? } else {
if (buffer instanceof Uint8Array) { // Extract ArrayBuffer from Uint8Array
bb = new ByteBuffer(0, littleEndian, noAssert);
if (buffer.length > 0) { // Avoid references to more than one EMPTY_BUFFER
bb.buffer = buffer.buffer;
bb.offset = buffer.byteOffset;
bb.limit = buffer.byteOffset + buffer.byteLength;
//? if (DATAVIEW)
bb.view = new DataView(buffer.buffer);
//? else
bb.view = new Uint8Array(buffer.buffer);
}
} else if (buffer instanceof ArrayBuffer) { // Reuse ArrayBuffer
bb = new ByteBuffer(0, littleEndian, noAssert);
if (buffer.byteLength > 0) {
bb.buffer = buffer;
bb.offset = 0;
bb.limit = buffer.byteLength;
//? if (DATAVIEW)
bb.view = buffer.byteLength > 0 ? new DataView(buffer) : null;
//? else
bb.view = buffer.byteLength > 0 ? new Uint8Array(buffer) : null;
}
} else if (Object.prototype.toString.call(buffer) === "[object Array]") { // Create from octets
bb = new ByteBuffer(buffer.length, littleEndian, noAssert);
bb.limit = buffer.length;
for (var i=0; i<buffer.length; ++i)
//? if (DATAVIEW)
bb.view.setUint8(i, buffer[i]);
//? else
bb.view[i] = buffer[i];
} else
throw TypeError("Illegal buffer"); // Otherwise fail
//? }
return bb;
};

77
node_modules/bytebuffer/src/methods/toBuffer.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
/**
* Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between
* {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.
* @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory if
* possible. Defaults to `false`
//? if (NODE) {
* @returns {!Buffer} Contents as a Buffer
//? } else {
* @returns {!ArrayBuffer} Contents as an ArrayBuffer
//? }
* @expose
*/
ByteBufferPrototype.toBuffer = function(forceCopy) {
var offset = this.offset,
limit = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE('offset', 'limit');
}
//? if (NODE) {
if (forceCopy) {
var buffer = new Buffer(limit - offset);
this.buffer.copy(buffer, 0, offset, limit);
return buffer;
} else {
if (offset === 0 && limit === this.buffer.length)
return this.buffer;
else
return this.buffer.slice(offset, limit);
}
//? } else {
// NOTE: It's not possible to have another ArrayBuffer reference the same memory as the backing buffer. This is
// possible with Uint8Array#subarray only, but we have to return an ArrayBuffer by contract. So:
if (!forceCopy && offset === 0 && limit === this.buffer.byteLength)
return this.buffer;
if (offset === limit)
return EMPTY_BUFFER;
var buffer = new ArrayBuffer(limit - offset);
new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(offset, limit), 0);
return buffer;
//? }
};
//? if (NODE) {
/**
* Returns a copy of the backing buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between
* {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.
* @returns {!ArrayBuffer} Contents as an ArrayBuffer
*/
ByteBufferPrototype.toArrayBuffer = function() {
var offset = this.offset,
limit = this.limit;
if (!this.noAssert) {
//? ASSERT_RANGE('offset', 'limit');
}
var ab = new ArrayBuffer(limit - offset);
if (memcpy) { // Fast
memcpy(ab, 0, this.buffer, offset, limit);
} else { // Slow
var dst = new Uint8Array(ab);
for (var i=offset; i<limit; ++i)
dst[i-offset] = this.buffer[i];
}
return ab;
};
//? } else {
/**
* Returns a raw buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between
* {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. This is an alias of {@link ByteBuffer#toBuffer}.
* @function
* @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory.
* Defaults to `false`
* @returns {!ArrayBuffer} Contents as an ArrayBuffer
* @expose
*/
ByteBufferPrototype.toArrayBuffer = ByteBufferPrototype.toBuffer;
//? }

43
node_modules/bytebuffer/src/methods/toString.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
/**
* Converts the ByteBuffer's contents to a string.
* @param {string=} encoding Output encoding. Returns an informative string representation if omitted but also allows
* direct conversion to "utf8", "hex", "base64" and "binary" encoding. "debug" returns a hex representation with
* highlighted offsets.
* @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset}
* @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
* @returns {string} String representation
* @throws {Error} If `encoding` is invalid
* @expose
*/
ByteBufferPrototype.toString = function(encoding, begin, end) {
if (typeof encoding === 'undefined')
return "ByteBuffer/*?= NODE ? 'NB' : 'AB'+(DATAVIEW ? '_DataView' : '') */(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";
if (typeof encoding === 'number')
encoding = "utf8",
begin = encoding,
end = begin;
switch (encoding) {
//? if (ENCODINGS) {
//? if (UTF8) {
case "utf8":
return this.toUTF8(begin, end);
//? } if (BASE64) {
case "base64":
return this.toBase64(begin, end);
//? } if (HEX) {
case "hex":
return this.toHex(begin, end);
//? } if (BINARY) {
case "binary":
return this.toBinary(begin, end);
//? } if (DEBUG) {
case "debug":
return this.toDebug();
case "columns":
return this.toColumns();
//? }
//? } // ENCODINGS
default:
throw Error("Unsupported encoding: "+encoding);
}
};

89
node_modules/bytebuffer/src/types/bytes/bitset.js generated vendored Normal file
View File

@ -0,0 +1,89 @@
/**
* Writes the array as a bitset.
* @param {Array<boolean>} value Array of booleans to write
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
* @returns {!ByteBuffer}
* @expose
*/
ByteBufferPrototype.writeBitSet = function(value, offset) {
//? RELATIVE()
if (!this.noAssert) {
if (!(value instanceof Array))
throw TypeError("Illegal BitSet: Not an array");
//? ASSERT_OFFSET();
}
var start = offset,
bits = value.length,
bytes = (bits >> 3),
bit = 0,
k;
offset += this.writeVarint32(bits,offset);
while(bytes--) {
k = (!!value[bit++] & 1) |
((!!value[bit++] & 1) << 1) |
((!!value[bit++] & 1) << 2) |
((!!value[bit++] & 1) << 3) |
((!!value[bit++] & 1) << 4) |
((!!value[bit++] & 1) << 5) |
((!!value[bit++] & 1) << 6) |
((!!value[bit++] & 1) << 7);
this.writeByte(k,offset++);
}
if(bit < bits) {
var m = 0; k = 0;
while(bit < bits) k = k | ((!!value[bit++] & 1) << (m++));
this.writeByte(k,offset++);
}
if (relative) {
this.offset = offset;
return this;
}
return offset - start;
}
/**
* Reads a BitSet as an array of booleans.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
* @returns {Array<boolean>
* @expose
*/
ByteBufferPrototype.readBitSet = function(offset) {
//? RELATIVE()
var ret = this.readVarint32(offset),
bits = ret.value,
bytes = (bits >> 3),
bit = 0,
value = [],
k;
offset += ret.length;
while(bytes--) {
k = this.readByte(offset++);
value[bit++] = !!(k & 0x01);
value[bit++] = !!(k & 0x02);
value[bit++] = !!(k & 0x04);
value[bit++] = !!(k & 0x08);
value[bit++] = !!(k & 0x10);
value[bit++] = !!(k & 0x20);
value[bit++] = !!(k & 0x40);
value[bit++] = !!(k & 0x80);
}
if(bit < bits) {
var m = 0;
k = this.readByte(offset++);
while(bit < bits) value[bit++] = !!((k >> (m++)) & 1);
}
if (relative) {
this.offset = offset;
}
return value;
}

34
node_modules/bytebuffer/src/types/bytes/bytes.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/**
* Reads the specified number of bytes.
* @param {number} length Number of bytes to read
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
* @returns {!ByteBuffer}
* @expose
*/
ByteBufferPrototype.readBytes = function(length, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET('length');
}
var slice = this.slice(offset, offset + length);
//? RELATIVE('length');
return slice;
};
/**
* Writes a payload of bytes. This is an alias of {@link ByteBuffer#append}.
* @function
//? if (NODE) {
* @param {!ByteBuffer|!Buffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its
* offsets will be modified according to the performed read operation.
//? } else {
* @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its offsets
* will be modified according to the performed read operation.
//? }
* @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeBytes = ByteBufferPrototype.append;

81
node_modules/bytebuffer/src/types/floats/float32.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
//? if (FLOAT32) {
// types/floats/float32
//? if (!NODE && !DATAVIEW) {
//? include("ieee754.js");
//? }
/**
* Writes a 32bit float.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeFloat32 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
if (typeof value !== 'number')
throw TypeError("Illegal value: "+value+" (not a number)");
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(4);
//? if (NODE) { // FIXME: Is there any way to inline the following in a sane way?
this.littleEndian
? this.buffer.writeFloatLE(value, offset, true)
: this.buffer.writeFloatBE(value, offset, true);
//? } else if (DATAVIEW)
this.view.setFloat32(offset, value, this.littleEndian);
//? else
ieee754_write(this.view, value, offset, this.littleEndian, 23, 4);
//? RELATIVE(4);
return this;
};
//? if (ALIASES) {
/**
* Writes a 32bit float. This is an alias of {@link ByteBuffer#writeFloat32}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeFloat = ByteBufferPrototype.writeFloat32;
//? }
/**
* Reads a 32bit float.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number}
* @expose
*/
ByteBufferPrototype.readFloat32 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(4);
}
//? if (NODE) {
var value = this.littleEndian
? this.buffer.readFloatLE(offset, true)
: this.buffer.readFloatBE(offset, true);
//? } else if (DATAVIEW)
var value = this.view.getFloat32(offset, this.littleEndian);
//? else
var value = ieee754_read(this.view, offset, this.littleEndian, 23, 4);
//? RELATIVE(4);
return value;
};
//? if (ALIASES) {
/**
* Reads a 32bit float. This is an alias of {@link ByteBuffer#readFloat32}.
* @function
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number}
* @expose
*/
ByteBufferPrototype.readFloat = ByteBufferPrototype.readFloat32;
//? }
//? }

77
node_modules/bytebuffer/src/types/floats/float64.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
//? if (FLOAT64) {
// types/floats/float64
/**
* Writes a 64bit float.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeFloat64 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
if (typeof value !== 'number')
throw TypeError("Illegal value: "+value+" (not a number)");
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(8);
//? if (NODE) {
this.littleEndian
? this.buffer.writeDoubleLE(value, offset, true)
: this.buffer.writeDoubleBE(value, offset, true);
//? } else if (DATAVIEW)
this.view.setFloat64(offset, value, this.littleEndian);
//? else
ieee754_write(this.view, value, offset, this.littleEndian, 52, 8);
//? RELATIVE(8);
return this;
};
//? if (ALIASES) {
/**
* Writes a 64bit float. This is an alias of {@link ByteBuffer#writeFloat64}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeDouble = ByteBufferPrototype.writeFloat64;
//? }
/**
* Reads a 64bit float.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {number}
* @expose
*/
ByteBufferPrototype.readFloat64 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(8);
}
//? if (NODE) {
var value = this.littleEndian
? this.buffer.readDoubleLE(offset, true)
: this.buffer.readDoubleBE(offset, true);
//? } else if (DATAVIEW)
var value = this.view.getFloat64(offset, this.littleEndian);
//? else
var value = ieee754_read(this.view, offset, this.littleEndian, 52, 8);
//? RELATIVE(8);
return value;
};
//? if (ALIASES) {
/**
* Reads a 64bit float. This is an alias of {@link ByteBuffer#readFloat64}.
* @function
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {number}
* @expose
*/
ByteBufferPrototype.readDouble = ByteBufferPrototype.readFloat64;
//? }
//? }

130
node_modules/bytebuffer/src/types/floats/ieee754.js generated vendored Normal file
View File

@ -0,0 +1,130 @@
/*
ieee754 - https://github.com/feross/ieee754
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/**
* Reads an IEEE754 float from a byte array.
* @param {!Array} buffer
* @param {number} offset
* @param {boolean} isLE
* @param {number} mLen
* @param {number} nBytes
* @returns {number}
* @inner
*/
function ieee754_read(buffer, offset, isLE, mLen, nBytes) {
var e, m,
eLen = nBytes * 8 - mLen - 1,
eMax = (1 << eLen) - 1,
eBias = eMax >> 1,
nBits = -7,
i = isLE ? (nBytes - 1) : 0,
d = isLE ? -1 : 1,
s = buffer[offset + i];
i += d;
e = s & ((1 << (-nBits)) - 1);
s >>= (-nBits);
nBits += eLen;
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
m = e & ((1 << (-nBits)) - 1);
e >>= (-nBits);
nBits += mLen;
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
if (e === 0) {
e = 1 - eBias;
} else if (e === eMax) {
return m ? NaN : ((s ? -1 : 1) * Infinity);
} else {
m = m + Math.pow(2, mLen);
e = e - eBias;
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
}
/**
* Writes an IEEE754 float to a byte array.
* @param {!Array} buffer
* @param {number} value
* @param {number} offset
* @param {boolean} isLE
* @param {number} mLen
* @param {number} nBytes
* @inner
*/
function ieee754_write(buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c,
eLen = nBytes * 8 - mLen - 1,
eMax = (1 << eLen) - 1,
eBias = eMax >> 1,
rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
i = isLE ? 0 : (nBytes - 1),
d = isLE ? 1 : -1,
s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e = eMax;
} else {
e = Math.floor(Math.log(value) / Math.LN2);
if (value * (c = Math.pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) {
value += rt / c;
} else {
value += rt * Math.pow(2, 1 - eBias);
}
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen);
e = e + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e = 0;
}
}
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
e = (e << mLen) | m;
eLen += mLen;
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
buffer[offset + i - d] |= s * 128;
}

167
node_modules/bytebuffer/src/types/ints/int16.js generated vendored Normal file
View File

@ -0,0 +1,167 @@
//? if (INT16) {
// types/ints/int16
/**
* Writes a 16bit signed integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @throws {TypeError} If `offset` or `value` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.writeInt16 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value');
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(2);
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
if (this.littleEndian) {
/*?= dst */[offset+1] = (value & 0xFF00) >>> 8;
/*?= dst */[offset ] = value & 0x00FF;
} else {
/*?= dst */[offset] = (value & 0xFF00) >>> 8;
/*?= dst */[offset+1] = value & 0x00FF;
}
//? } else
this.view.setInt16(offset, value, this.littleEndian);
//? RELATIVE(2);
return this;
};
//? if (ALIASES) {
/**
* Writes a 16bit signed integer. This is an alias of {@link ByteBuffer#writeInt16}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @throws {TypeError} If `offset` or `value` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.writeShort = ByteBufferPrototype.writeInt16;
//? }
/**
* Reads a 16bit signed integer.
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @returns {number} Value read
* @throws {TypeError} If `offset` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.readInt16 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(2);
}
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
var value = 0;
if (this.littleEndian) {
value = /*?= dst */[offset ];
value |= /*?= dst */[offset+1] << 8;
} else {
value = /*?= dst */[offset ] << 8;
value |= /*?= dst */[offset+1];
}
if ((value & 0x8000) === 0x8000) value = -(0xFFFF - value + 1); // Cast to signed
//? } else
var value = this.view.getInt16(offset, this.littleEndian);
//? RELATIVE(2);
return value;
};
//? if (ALIASES) {
/**
* Reads a 16bit signed integer. This is an alias of {@link ByteBuffer#readInt16}.
* @function
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @returns {number} Value read
* @throws {TypeError} If `offset` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.readShort = ByteBufferPrototype.readInt16;
//? }
/**
* Writes a 16bit unsigned integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @throws {TypeError} If `offset` or `value` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.writeUint16 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value', true);
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(2);
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
if (this.littleEndian) {
/*?= dst */[offset+1] = (value & 0xFF00) >>> 8;
/*?= dst */[offset ] = value & 0x00FF;
} else {
/*?= dst */[offset] = (value & 0xFF00) >>> 8;
/*?= dst */[offset+1] = value & 0x00FF;
}
//? } else
this.view.setUint16(offset, value, this.littleEndian);
//? RELATIVE(2);
return this;
};
/**
* Writes a 16bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint16}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @throws {TypeError} If `offset` or `value` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.writeUInt16 = ByteBufferPrototype.writeUint16;
/**
* Reads a 16bit unsigned integer.
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @returns {number} Value read
* @throws {TypeError} If `offset` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.readUint16 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(2);
}
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
var value = 0;
if (this.littleEndian) {
value = /*?= dst */[offset ];
value |= /*?= dst */[offset+1] << 8;
} else {
value = /*?= dst */[offset ] << 8;
value |= /*?= dst */[offset+1];
}
//? } else
var value = this.view.getUint16(offset, this.littleEndian);
//? RELATIVE(2);
return value;
};
/**
* Reads a 16bit unsigned integer. This is an alias of {@link ByteBuffer#readUint16}.
* @function
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
* @returns {number} Value read
* @throws {TypeError} If `offset` is not a valid number
* @throws {RangeError} If `offset` is out of bounds
* @expose
*/
ByteBufferPrototype.readUInt16 = ByteBufferPrototype.readUint16;
//? }

125
node_modules/bytebuffer/src/types/ints/int32.js generated vendored Normal file
View File

@ -0,0 +1,125 @@
//? if (INT32) {
// types/ints/int32
/**
* Writes a 32bit signed integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @expose
*/
ByteBufferPrototype.writeInt32 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value');
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(4);
//? if (NODE || !DATAVIEW) {
//? WRITE_UINT32_ARRAY();
//? } else
this.view.setInt32(offset, value, this.littleEndian);
//? RELATIVE(4);
return this;
};
//? if (ALIASES) {
/**
* Writes a 32bit signed integer. This is an alias of {@link ByteBuffer#writeInt32}.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @expose
*/
ByteBufferPrototype.writeInt = ByteBufferPrototype.writeInt32;
//? }
/**
* Reads a 32bit signed integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readInt32 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(4);
}
//? if (NODE || !DATAVIEW) {
var value = 0;
//? READ_UINT32_ARRAY();
value |= 0; // Cast to signed
//? } else
var value = this.view.getInt32(offset, this.littleEndian);
//? RELATIVE(4);
return value;
};
//? if (ALIASES) {
/**
* Reads a 32bit signed integer. This is an alias of {@link ByteBuffer#readInt32}.
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readInt = ByteBufferPrototype.readInt32;
//? }
/**
* Writes a 32bit unsigned integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @expose
*/
ByteBufferPrototype.writeUint32 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value', true);
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(4);
//? if (NODE || !DATAVIEW) {
//? WRITE_UINT32_ARRAY();
//? } else
this.view.setUint32(offset, value, this.littleEndian);
//? RELATIVE(4);
return this;
};
/**
* Writes a 32bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint32}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @expose
*/
ByteBufferPrototype.writeUInt32 = ByteBufferPrototype.writeUint32;
/**
* Reads a 32bit unsigned integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readUint32 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(4);
}
//? if (NODE || !DATAVIEW) {
var value = 0;
//? READ_UINT32_ARRAY();
//? } else
var value = this.view.getUint32(offset, this.littleEndian);
//? RELATIVE(4);
return value;
};
/**
* Reads a 32bit unsigned integer. This is an alias of {@link ByteBuffer#readUint32}.
* @function
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readUInt32 = ByteBufferPrototype.readUint32;
//? }

194
node_modules/bytebuffer/src/types/ints/int64.js generated vendored Normal file
View File

@ -0,0 +1,194 @@
//? if (INT64) {
// types/ints/int64
if (Long) {
/**
* Writes a 64bit signed integer.
* @param {number|!Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeInt64 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_LONG('value');
//? ASSERT_OFFSET();
}
//? LONG('value');
//? ENSURE_CAPACITY(8);
//? if (NODE || !DATAVIEW) {
var lo = value.low,
hi = value.high;
if (this.littleEndian) {
//? WRITE_UINT32_ARRAY('lo', undefined, undefined, true);
offset += 4;
//? WRITE_UINT32_ARRAY('hi', undefined, undefined, true);
} else {
//? WRITE_UINT32_ARRAY('hi', undefined, undefined, false);
offset += 4;
//? WRITE_UINT32_ARRAY('lo', undefined, undefined, false);
}
//? } else {
if (this.littleEndian) {
this.view.setInt32(offset , value.low , true);
this.view.setInt32(offset+4, value.high, true);
} else {
this.view.setInt32(offset , value.high, false);
this.view.setInt32(offset+4, value.low , false);
}
//? }
//? RELATIVE(8);
return this;
};
//? if (ALIASES) {
/**
* Writes a 64bit signed integer. This is an alias of {@link ByteBuffer#writeInt64}.
* @param {number|!Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeLong = ByteBufferPrototype.writeInt64;
//? }
/**
* Reads a 64bit signed integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!Long}
* @expose
*/
ByteBufferPrototype.readInt64 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(8);
}
//? if (NODE || !DATAVIEW) {
var lo = 0,
hi = 0;
if (this.littleEndian) {
//? READ_UINT32_ARRAY('lo', undefined, undefined, true);
offset += 4;
//? READ_UINT32_ARRAY('hi', undefined, undefined, true);
} else {
//? READ_UINT32_ARRAY('hi', undefined, undefined, false);
offset += 4;
//? READ_UINT32_ARRAY('lo', undefined, undefined, false);
}
var value = new Long(lo, hi, false);
//? } else {
var value = this.littleEndian
? new Long(this.view.getInt32(offset , true ), this.view.getInt32(offset+4, true ), false)
: new Long(this.view.getInt32(offset+4, false), this.view.getInt32(offset , false), false);
//? }
//? RELATIVE(8);
return value;
};
//? if (ALIASES) {
/**
* Reads a 64bit signed integer. This is an alias of {@link ByteBuffer#readInt64}.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!Long}
* @expose
*/
ByteBufferPrototype.readLong = ByteBufferPrototype.readInt64;
//? }
/**
* Writes a 64bit unsigned integer.
* @param {number|!Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeUint64 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_LONG('value');
//? ASSERT_OFFSET();
}
//? LONG('value');
//? ENSURE_CAPACITY(8);
//? if (NODE || !DATAVIEW) {
var lo = value.low,
hi = value.high;
if (this.littleEndian) {
//? WRITE_UINT32_ARRAY('lo', undefined, undefined, true);
offset += 4;
//? WRITE_UINT32_ARRAY('hi', undefined, undefined, true);
} else {
//? WRITE_UINT32_ARRAY('hi', undefined, undefined, false);
offset += 4;
//? WRITE_UINT32_ARRAY('lo', undefined, undefined, false);
}
//? } else {
if (this.littleEndian) {
this.view.setInt32(offset , value.low , true);
this.view.setInt32(offset+4, value.high, true);
} else {
this.view.setInt32(offset , value.high, false);
this.view.setInt32(offset+4, value.low , false);
}
//? }
//? RELATIVE(8);
return this;
};
/**
* Writes a 64bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint64}.
* @function
* @param {number|!Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeUInt64 = ByteBufferPrototype.writeUint64;
/**
* Reads a 64bit unsigned integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!Long}
* @expose
*/
ByteBufferPrototype.readUint64 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(8);
}
//? if (NODE || !DATAVIEW) {
var lo = 0,
hi = 0;
if (this.littleEndian) {
//? READ_UINT32_ARRAY('lo', undefined, undefined, true);
offset += 4;
//? READ_UINT32_ARRAY('hi', undefined, undefined, true);
} else {
//? READ_UINT32_ARRAY('hi', undefined, undefined, false);
offset += 4;
//? READ_UINT32_ARRAY('lo', undefined, undefined, false);
}
var value = new Long(lo, hi, true);
//? } else {
var value = this.littleEndian
? new Long(this.view.getInt32(offset , true ), this.view.getInt32(offset+4, true ), true)
: new Long(this.view.getInt32(offset+4, false), this.view.getInt32(offset , false), true);
//? }
//? RELATIVE(8);
return value;
};
/**
* Reads a 64bit unsigned integer. This is an alias of {@link ByteBuffer#readUint64}.
* @function
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
* @returns {!Long}
* @expose
*/
ByteBufferPrototype.readUInt64 = ByteBufferPrototype.readUint64;
} // Long
//? }

137
node_modules/bytebuffer/src/types/ints/int8.js generated vendored Normal file
View File

@ -0,0 +1,137 @@
//? if (INT8) {
// types/ints/int8
/**
* Writes an 8bit signed integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeInt8 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value');
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(1);
//? if (NODE)
this.buffer[offset] = value;
//? else if (DATAVIEW)
this.view.setInt8(offset, value);
//? else
this.view[offset] = value;
//? RELATIVE(1);
return this;
};
/**
* Writes an 8bit signed integer. This is an alias of {@link ByteBuffer#writeInt8}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeByte = ByteBufferPrototype.writeInt8;
/**
* Reads an 8bit signed integer.
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readInt8 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
//? if (NODE) {
var value = this.buffer[offset];
if ((value & 0x80) === 0x80) value = -(0xFF - value + 1); // Cast to signed
//? } else if (DATAVIEW) {
var value = this.view.getInt8(offset);
//? } else {
var value = this.view[offset];
if ((value & 0x80) === 0x80) value = -(0xFF - value + 1); // Cast to signed
//? }
//? RELATIVE(1);
return value;
};
//? if (ALIASES) {
/**
* Reads an 8bit signed integer. This is an alias of {@link ByteBuffer#readInt8}.
* @function
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readByte = ByteBufferPrototype.readInt8;
//? }
/**
* Writes an 8bit unsigned integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeUint8 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value', true);
//? ASSERT_OFFSET();
}
//? ENSURE_CAPACITY(1);
//? if (NODE)
this.buffer[offset] = value;
//? else if (DATAVIEW)
this.view.setUint8(offset, value);
//? else
this.view[offset] = value;
//? RELATIVE(1);
return this;
};
/**
* Writes an 8bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint8}.
* @function
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {!ByteBuffer} this
* @expose
*/
ByteBufferPrototype.writeUInt8 = ByteBufferPrototype.writeUint8;
/**
* Reads an 8bit unsigned integer.
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readUint8 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
//? if (NODE)
var value = this.buffer[offset];
//? else if (DATAVIEW)
var value = this.view.getUint8(offset);
//? else
var value = this.view[offset];
//? RELATIVE(1);
return value;
};
/**
* Reads an 8bit unsigned integer. This is an alias of {@link ByteBuffer#readUint8}.
* @function
* @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
* @returns {number} Value read
* @expose
*/
ByteBufferPrototype.readUInt8 = ByteBufferPrototype.readUint8;
//? }

110
node_modules/bytebuffer/src/types/strings/cstring.js generated vendored Normal file
View File

@ -0,0 +1,110 @@
//? if (CSTRING) {
// types/strings/cstring
/**
* Writes a NULL-terminated UTF8 encoded string. For this to work the specified string must not contain any NULL
* characters itself.
* @param {string} str String to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* contained in `str` + 1 if omitted.
* @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written
* @expose
*/
ByteBufferPrototype.writeCString = function(str, offset) {
//? RELATIVE();
var i,
k = str.length;
if (!this.noAssert) {
if (typeof str !== 'string')
throw TypeError("Illegal str: Not a string");
for (i=0; i<k; ++i) {
if (str.charCodeAt(i) === 0)
throw RangeError("Illegal str: Contains NULL-characters");
}
//? ASSERT_OFFSET();
}
// UTF8 strings do not contain zero bytes in between except for the zero character, so:
//? if (NODE) {
k = Buffer.byteLength(str, "utf8");
//? ENSURE_CAPACITY('k+1');
offset += this.buffer.write(str, offset, k, "utf8");
this.buffer[offset++] = 0;
//? } else {
k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
//? ENSURE_CAPACITY('k+1');
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
//? if (DATAVIEW)
this.view.setUint8(offset++, b);
//? else
this.view[offset++] = b;
}.bind(this));
//? if (DATAVIEW)
this.view.setUint8(offset++, 0);
//? else
this.view[offset++] = 0;
//? }
if (relative) {
this.offset = offset;
return this;
}
return k;
};
/**
* Reads a NULL-terminated UTF8 encoded string. For this to work the string read must not contain any NULL characters
* itself.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
* read and the actual number of bytes read.
* @expose
*/
ByteBufferPrototype.readCString = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
var start = offset,
temp;
// UTF8 strings do not contain zero bytes in between except for the zero character itself, so:
//? if (NODE) {
do {
if (offset >= this.buffer.length)
throw RangeError("Index out of range: "+offset+" <= "+this.buffer.length);
temp = this.buffer[offset++];
} while (temp !== 0);
var str = this.buffer.toString("utf8", start, offset-1);
if (relative) {
this.offset = offset;
return str;
} else {
return {
"string": str,
"length": offset - start
};
}
//? } else { // getUint8 asserts on its own
var sd, b = -1;
utfx.decodeUTF8toUTF16(function() {
if (b === 0) return null;
if (offset >= this.limit)
throw RangeError("Illegal range: Truncated data, "+offset+" < "+this.limit);
//? if (DATAVIEW)
b = this.view.getUint8(offset++);
//? else
b = this.view[offset++];
return b === 0 ? null : b;
}.bind(this), sd = stringDestination(), true);
if (relative) {
this.offset = offset;
return sd();
} else {
return {
"string": sd(),
"length": offset - start
};
}
//? }
};
//? }

81
node_modules/bytebuffer/src/types/strings/istring.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
//? if (ISTRING) {
// types/strings/istring
/**
* Writes a length as uint32 prefixed UTF8 encoded string.
* @param {string} str String to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written
* @expose
* @see ByteBuffer#writeVarint32
*/
ByteBufferPrototype.writeIString = function(str, offset) {
//? RELATIVE();
if (!this.noAssert) {
if (typeof str !== 'string')
throw TypeError("Illegal str: Not a string");
//? ASSERT_OFFSET();
}
var start = offset,
k;
//? if (NODE) {
k = Buffer.byteLength(str, "utf8");
//? ENSURE_CAPACITY('4+k');
//? WRITE_UINT32_ARRAY('k');
offset += 4;
offset += this.buffer.write(str, offset, k, "utf8");
//? } else {
k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
//? ENSURE_CAPACITY('4+k');
//? if (DATAVIEW)
this.view.setUint32(offset, k, this.littleEndian);
//? else
//? WRITE_UINT32_ARRAY('k');
offset += 4;
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
//? if (DATAVIEW)
this.view.setUint8(offset++, b);
//? else
this.view[offset++] = b;
}.bind(this));
if (offset !== start + 4 + k)
throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+4+k));
//? }
if (relative) {
this.offset = offset;
return this;
}
return offset - start;
};
/**
* Reads a length as uint32 prefixed UTF8 encoded string.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
* read and the actual number of bytes read.
* @expose
* @see ByteBuffer#readVarint32
*/
ByteBufferPrototype.readIString = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(4);
}
var start = offset;
var len = this.readUint32(offset);
var str = this.readUTF8String(len, ByteBuffer.METRICS_BYTES, offset += 4);
offset += str['length'];
if (relative) {
this.offset = offset;
return str['string'];
} else {
return {
'string': str['string'],
'length': offset - start
};
}
};
//? }

214
node_modules/bytebuffer/src/types/strings/utf8string.js generated vendored Normal file
View File

@ -0,0 +1,214 @@
//? if (UTF8STRING && UTF8) {
// types/strings/utf8string
/**
* Metrics representing number of UTF8 characters. Evaluates to `c`.
* @type {string}
* @const
* @expose
*/
ByteBuffer.METRICS_CHARS = 'c';
/**
* Metrics representing number of bytes. Evaluates to `b`.
* @type {string}
* @const
* @expose
*/
ByteBuffer.METRICS_BYTES = 'b';
/**
* Writes an UTF8 encoded string.
* @param {string} str String to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted.
* @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written.
* @expose
*/
ByteBufferPrototype.writeUTF8String = function(str, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET();
}
var k;
//? if (NODE) {
k = Buffer.byteLength(str, "utf8");
//? ENSURE_CAPACITY('k');
offset += this.buffer.write(str, offset, k, "utf8");
if (relative) {
this.offset = offset;
return this;
}
return k;
//? } else {
var start = offset;
k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
//? ENSURE_CAPACITY('k');
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
//? if (DATAVIEW)
this.view.setUint8(offset++, b);
//? else
this.view[offset++] = b;
}.bind(this));
if (relative) {
this.offset = offset;
return this;
}
return offset - start;
//? }
};
//? if (ALIASES) {
/**
* Writes an UTF8 encoded string. This is an alias of {@link ByteBuffer#writeUTF8String}.
* @function
* @param {string} str String to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted.
* @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written.
* @expose
*/
ByteBufferPrototype.writeString = ByteBufferPrototype.writeUTF8String;
//? }
/**
* Calculates the number of UTF8 characters of a string. JavaScript itself uses UTF-16, so that a string's
* `length` property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF.
* @param {string} str String to calculate
* @returns {number} Number of UTF8 characters
* @expose
*/
ByteBuffer.calculateUTF8Chars = function(str) {
return utfx.calculateUTF16asUTF8(stringSource(str))[0];
};
/**
* Calculates the number of UTF8 bytes of a string.
* @param {string} str String to calculate
* @returns {number} Number of UTF8 bytes
* @expose
*/
ByteBuffer.calculateUTF8Bytes = function(str) {
//? if (NODE) {
if (typeof str !== 'string')
throw TypeError("Illegal argument: "+(typeof str));
return Buffer.byteLength(str, "utf8");
//? } else
return utfx.calculateUTF16asUTF8(stringSource(str))[1];
};
//? if (ALIASES) {
/**
* Calculates the number of UTF8 bytes of a string. This is an alias of {@link ByteBuffer.calculateUTF8Bytes}.
* @function
* @param {string} str String to calculate
* @returns {number} Number of UTF8 bytes
* @expose
*/
ByteBuffer.calculateString = ByteBuffer.calculateUTF8Bytes;
//? }
/**
* Reads an UTF8 encoded string.
* @param {number} length Number of characters or bytes to read.
* @param {string=} metrics Metrics specifying what `length` is meant to count. Defaults to
* {@link ByteBuffer.METRICS_CHARS}.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
* read and the actual number of bytes read.
* @expose
*/
ByteBufferPrototype.readUTF8String = function(length, metrics, offset) {
if (typeof metrics === 'number') {
offset = metrics;
metrics = undefined;
}
//? RELATIVE();
if (typeof metrics === 'undefined') metrics = ByteBuffer.METRICS_CHARS;
if (!this.noAssert) {
//? ASSERT_INTEGER('length');
//? ASSERT_OFFSET();
}
var i = 0,
start = offset,
//? if (NODE)
temp,
sd;
if (metrics === ByteBuffer.METRICS_CHARS) { // The same for node and the browser
sd = stringDestination();
utfx.decodeUTF8(function() {
//? if (NODE)
return i < length && offset < this.limit ? this.buffer[offset++] : null;
//? else if (DATAVIEW)
return i < length && offset < this.limit ? this.view.getUint8(offset++) : null;
//? else
return i < length && offset < this.limit ? this.view[offset++] : null;
}.bind(this), function(cp) {
++i; utfx.UTF8toUTF16(cp, sd);
});
if (i !== length)
throw RangeError("Illegal range: Truncated data, "+i+" == "+length);
if (relative) {
this.offset = offset;
return sd();
} else {
return {
"string": sd(),
"length": offset - start
};
}
} else if (metrics === ByteBuffer.METRICS_BYTES) {
if (!this.noAssert) {
//? ASSERT_OFFSET('length');
}
//? if (NODE) {
temp = this.buffer.toString("utf8", offset, offset+length);
if (relative) {
this.offset += length;
return temp;
} else {
return {
'string': temp,
'length': length
};
}
//? } else {
var k = offset + length;
utfx.decodeUTF8toUTF16(function() {
//? if (DATAVIEW)
return offset < k ? this.view.getUint8(offset++) : null;
//? else
return offset < k ? this.view[offset++] : null;
}.bind(this), sd = stringDestination(), this.noAssert);
if (offset !== k)
throw RangeError("Illegal range: Truncated data, "+offset+" == "+k);
if (relative) {
this.offset = offset;
return sd();
} else {
return {
'string': sd(),
'length': offset - start
};
}
//? }
} else
throw TypeError("Unsupported metrics: "+metrics);
};
//? if (ALIASES) {
/**
* Reads an UTF8 encoded string. This is an alias of {@link ByteBuffer#readUTF8String}.
* @function
* @param {number} length Number of characters or bytes to read
* @param {number=} metrics Metrics specifying what `n` is meant to count. Defaults to
* {@link ByteBuffer.METRICS_CHARS}.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
* read and the actual number of bytes read.
* @expose
*/
ByteBufferPrototype.readString = ByteBufferPrototype.readUTF8String;
//? }
//? }

78
node_modules/bytebuffer/src/types/strings/vstring.js generated vendored Normal file
View File

@ -0,0 +1,78 @@
//? if (VSTRING && VARINTS && VARINT32) {
// types/strings/vstring
/**
* Writes a length as varint32 prefixed UTF8 encoded string.
* @param {string} str String to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written
* @expose
* @see ByteBuffer#writeVarint32
*/
ByteBufferPrototype.writeVString = function(str, offset) {
//? RELATIVE()
if (!this.noAssert) {
if (typeof str !== 'string')
throw TypeError("Illegal str: Not a string");
//? ASSERT_OFFSET();
}
var start = offset,
k, l;
//? if (NODE) {
k = Buffer.byteLength(str, "utf8");
l = ByteBuffer.calculateVarint32(k);
//? ENSURE_CAPACITY('l+k');
offset += this.writeVarint32(k, offset);
offset += this.buffer.write(str, offset, k, "utf8");
//? } else {
k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
l = ByteBuffer.calculateVarint32(k);
//? ENSURE_CAPACITY('l+k');
offset += this.writeVarint32(k, offset);
utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
//? if (DATAVIEW)
this.view.setUint8(offset++, b);
//? else
this.view[offset++] = b;
}.bind(this));
if (offset !== start+k+l)
throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+k+l));
//? }
if (relative) {
this.offset = offset;
return this;
}
return offset - start;
};
/**
* Reads a length as varint32 prefixed UTF8 encoded string.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
* read and the actual number of bytes read.
* @expose
* @see ByteBuffer#readVarint32
*/
ByteBufferPrototype.readVString = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
var start = offset;
var len = this.readVarint32(offset);
var str = this.readUTF8String(len['value'], ByteBuffer.METRICS_BYTES, offset += len['length']);
offset += str['length'];
if (relative) {
this.offset = offset;
return str['string'];
} else {
return {
'string': str['string'],
'length': offset - start
};
}
};
//? }

164
node_modules/bytebuffer/src/types/varints/varint32.js generated vendored Normal file
View File

@ -0,0 +1,164 @@
//? if (VARINT32) {
// types/varints/varint32
/**
* Maximum number of bytes required to store a 32bit base 128 variable-length integer.
* @type {number}
* @const
* @expose
*/
ByteBuffer.MAX_VARINT32_BYTES = 5;
/**
* Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer.
* @param {number} value Value to encode
* @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT32_BYTES}
* @expose
*/
ByteBuffer.calculateVarint32 = function(value) {
// ref: src/google/protobuf/io/coded_stream.cc
value = value >>> 0;
if (value < 1 << 7 ) return 1;
else if (value < 1 << 14) return 2;
else if (value < 1 << 21) return 3;
else if (value < 1 << 28) return 4;
else return 5;
};
/**
* Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding.
* @param {number} n Signed 32bit integer
* @returns {number} Unsigned zigzag encoded 32bit integer
* @expose
*/
ByteBuffer.zigZagEncode32 = function(n) {
return (((n |= 0) << 1) ^ (n >> 31)) >>> 0; // ref: src/google/protobuf/wire_format_lite.h
};
/**
* Decodes a zigzag encoded signed 32bit integer.
* @param {number} n Unsigned zigzag encoded 32bit integer
* @returns {number} Signed 32bit integer
* @expose
*/
ByteBuffer.zigZagDecode32 = function(n) {
return ((n >>> 1) ^ -(n & 1)) | 0; // // ref: src/google/protobuf/wire_format_lite.h
};
/**
* Writes a 32bit base 128 variable-length integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written
* @expose
*/
ByteBufferPrototype.writeVarint32 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_INTEGER('value');
//? ASSERT_OFFSET();
}
var size = ByteBuffer.calculateVarint32(value),
b;
//? ENSURE_CAPACITY('size');
value >>>= 0;
while (value >= 0x80) {
b = (value & 0x7f) | 0x80;
//? if (NODE)
this.buffer[offset++] = b;
//? else if (DATAVIEW)
this.view.setUint8(offset++, b);
//? else
this.view[offset++] = b;
value >>>= 7;
}
//? if (NODE)
this.buffer[offset++] = value;
//? else if (DATAVIEW)
this.view.setUint8(offset++, value);
//? else
this.view[offset++] = value;
if (relative) {
this.offset = offset;
return this;
}
return size;
};
/**
* Writes a zig-zag encoded (signed) 32bit base 128 variable-length integer.
* @param {number} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written
* @expose
*/
ByteBufferPrototype.writeVarint32ZigZag = function(value, offset) {
return this.writeVarint32(ByteBuffer.zigZagEncode32(value), offset);
};
/**
* Reads a 32bit base 128 variable-length integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read
* and the actual number of bytes read.
* @throws {Error} If it's not a valid varint. Has a property `truncated = true` if there is not enough data available
* to fully decode the varint.
* @expose
*/
ByteBufferPrototype.readVarint32 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
var c = 0,
value = 0 >>> 0,
b;
do {
if (!this.noAssert && offset > this.limit) {
var err = Error("Truncated");
err['truncated'] = true;
throw err;
}
//? if (NODE)
b = this.buffer[offset++];
//? else if (DATAVIEW)
b = this.view.getUint8(offset++);
//? else
b = this.view[offset++];
if (c < 5)
value |= (b & 0x7f) << (7*c);
++c;
} while ((b & 0x80) !== 0);
value |= 0;
if (relative) {
this.offset = offset;
return value;
}
return {
"value": value,
"length": c
};
};
/**
* Reads a zig-zag encoded (signed) 32bit base 128 variable-length integer.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read
* and the actual number of bytes read.
* @throws {Error} If it's not a valid varint
* @expose
*/
ByteBufferPrototype.readVarint32ZigZag = function(offset) {
var val = this.readVarint32(offset);
if (typeof val === 'object')
val["value"] = ByteBuffer.zigZagDecode32(val["value"]);
else
val = ByteBuffer.zigZagDecode32(val);
return val;
};
//? }

208
node_modules/bytebuffer/src/types/varints/varint64.js generated vendored Normal file
View File

@ -0,0 +1,208 @@
//? if (VARINT64) {
// types/varints/varint64
if (Long) {
/**
* Maximum number of bytes required to store a 64bit base 128 variable-length integer.
* @type {number}
* @const
* @expose
*/
ByteBuffer.MAX_VARINT64_BYTES = 10;
/**
* Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer.
* @param {number|!Long} value Value to encode
* @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT64_BYTES}
* @expose
*/
ByteBuffer.calculateVarint64 = function(value) {
//? LONG('value');
// ref: src/google/protobuf/io/coded_stream.cc
var part0 = value.toInt() >>> 0,
part1 = value.shiftRightUnsigned(28).toInt() >>> 0,
part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
if (part2 == 0) {
if (part1 == 0) {
if (part0 < 1 << 14)
return part0 < 1 << 7 ? 1 : 2;
else
return part0 < 1 << 21 ? 3 : 4;
} else {
if (part1 < 1 << 14)
return part1 < 1 << 7 ? 5 : 6;
else
return part1 < 1 << 21 ? 7 : 8;
}
} else
return part2 < 1 << 7 ? 9 : 10;
};
/**
* Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding.
* @param {number|!Long} value Signed long
* @returns {!Long} Unsigned zigzag encoded long
* @expose
*/
ByteBuffer.zigZagEncode64 = function(value) {
//? LONG('value', false);
// ref: src/google/protobuf/wire_format_lite.h
return value.shiftLeft(1).xor(value.shiftRight(63)).toUnsigned();
};
/**
* Decodes a zigzag encoded signed 64bit integer.
* @param {!Long|number} value Unsigned zigzag encoded long or JavaScript number
* @returns {!Long} Signed long
* @expose
*/
ByteBuffer.zigZagDecode64 = function(value) {
//? LONG('value', false);
// ref: src/google/protobuf/wire_format_lite.h
return value.shiftRightUnsigned(1).xor(value.and(Long.ONE).toSigned().negate()).toSigned();
};
/**
* Writes a 64bit base 128 variable-length integer.
* @param {number|Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written.
* @expose
*/
ByteBufferPrototype.writeVarint64 = function(value, offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_LONG('value');
//? ASSERT_OFFSET();
}
//? LONG('value', false);
var size = ByteBuffer.calculateVarint64(value),
part0 = value.toInt() >>> 0,
part1 = value.shiftRightUnsigned(28).toInt() >>> 0,
part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
//? ENSURE_CAPACITY('size');
switch (size) {
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
case 10: /*?= dst */[offset+9] = (part2 >>> 7) & 0x01;
case 9 : /*?= dst */[offset+8] = size !== 9 ? (part2 ) | 0x80 : (part2 ) & 0x7F;
case 8 : /*?= dst */[offset+7] = size !== 8 ? (part1 >>> 21) | 0x80 : (part1 >>> 21) & 0x7F;
case 7 : /*?= dst */[offset+6] = size !== 7 ? (part1 >>> 14) | 0x80 : (part1 >>> 14) & 0x7F;
case 6 : /*?= dst */[offset+5] = size !== 6 ? (part1 >>> 7) | 0x80 : (part1 >>> 7) & 0x7F;
case 5 : /*?= dst */[offset+4] = size !== 5 ? (part1 ) | 0x80 : (part1 ) & 0x7F;
case 4 : /*?= dst */[offset+3] = size !== 4 ? (part0 >>> 21) | 0x80 : (part0 >>> 21) & 0x7F;
case 3 : /*?= dst */[offset+2] = size !== 3 ? (part0 >>> 14) | 0x80 : (part0 >>> 14) & 0x7F;
case 2 : /*?= dst */[offset+1] = size !== 2 ? (part0 >>> 7) | 0x80 : (part0 >>> 7) & 0x7F;
case 1 : /*?= dst */[offset ] = size !== 1 ? (part0 ) | 0x80 : (part0 ) & 0x7F;
//? } else {
case 10: this.view.setUint8(offset+9, (part2 >>> 7) & 0x01);
case 9 : this.view.setUint8(offset+8, size !== 9 ? (part2 ) | 0x80 : (part2 ) & 0x7F);
case 8 : this.view.setUint8(offset+7, size !== 8 ? (part1 >>> 21) | 0x80 : (part1 >>> 21) & 0x7F);
case 7 : this.view.setUint8(offset+6, size !== 7 ? (part1 >>> 14) | 0x80 : (part1 >>> 14) & 0x7F);
case 6 : this.view.setUint8(offset+5, size !== 6 ? (part1 >>> 7) | 0x80 : (part1 >>> 7) & 0x7F);
case 5 : this.view.setUint8(offset+4, size !== 5 ? (part1 ) | 0x80 : (part1 ) & 0x7F);
case 4 : this.view.setUint8(offset+3, size !== 4 ? (part0 >>> 21) | 0x80 : (part0 >>> 21) & 0x7F);
case 3 : this.view.setUint8(offset+2, size !== 3 ? (part0 >>> 14) | 0x80 : (part0 >>> 14) & 0x7F);
case 2 : this.view.setUint8(offset+1, size !== 2 ? (part0 >>> 7) | 0x80 : (part0 >>> 7) & 0x7F);
case 1 : this.view.setUint8(offset , size !== 1 ? (part0 ) | 0x80 : (part0 ) & 0x7F);
//? }
}
if (relative) {
this.offset += size;
return this;
} else {
return size;
}
};
/**
* Writes a zig-zag encoded 64bit base 128 variable-length integer.
* @param {number|Long} value Value to write
* @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* written if omitted.
* @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written.
* @expose
*/
ByteBufferPrototype.writeVarint64ZigZag = function(value, offset) {
return this.writeVarint64(ByteBuffer.zigZagEncode64(value), offset);
};
/**
* Reads a 64bit base 128 variable-length integer. Requires Long.js.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and
* the actual number of bytes read.
* @throws {Error} If it's not a valid varint
* @expose
*/
ByteBufferPrototype.readVarint64 = function(offset) {
//? RELATIVE();
if (!this.noAssert) {
//? ASSERT_OFFSET(1);
}
// ref: src/google/protobuf/io/coded_stream.cc
var start = offset,
part0 = 0,
part1 = 0,
part2 = 0,
b = 0;
//? if (NODE || !DATAVIEW) { var dst = NODE ? 'this.buffer' : 'this.view';
b = /*?= dst */[offset++]; part0 = (b & 0x7F) ; if ( b & 0x80 ) {
b = /*?= dst */[offset++]; part0 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part0 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part0 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part1 = (b & 0x7F) ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part1 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part1 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part1 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part2 = (b & 0x7F) ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
b = /*?= dst */[offset++]; part2 |= (b & 0x7F) << 7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
throw Error("Buffer overrun"); }}}}}}}}}}
//? } else { // Asserts on its own
b = this.view.getUint8(offset++); part0 = (b & 0x7F) ; if (b & 0x80) {
b = this.view.getUint8(offset++); part0 |= (b & 0x7F) << 7; if (b & 0x80) {
b = this.view.getUint8(offset++); part0 |= (b & 0x7F) << 14; if (b & 0x80) {
b = this.view.getUint8(offset++); part0 |= (b & 0x7F) << 21; if (b & 0x80) {
b = this.view.getUint8(offset++); part1 = (b & 0x7F) ; if (b & 0x80) {
b = this.view.getUint8(offset++); part1 |= (b & 0x7F) << 7; if (b & 0x80) {
b = this.view.getUint8(offset++); part1 |= (b & 0x7F) << 14; if (b & 0x80) {
b = this.view.getUint8(offset++); part1 |= (b & 0x7F) << 21; if (b & 0x80) {
b = this.view.getUint8(offset++); part2 = (b & 0x7F) ; if (b & 0x80) {
b = this.view.getUint8(offset++); part2 |= (b & 0x7F) << 7; if (b & 0x80) {
throw Error("Buffer overrun"); }}}}}}}}}}
//? }
var value = Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, false);
if (relative) {
this.offset = offset;
return value;
} else {
return {
'value': value,
'length': offset-start
};
}
};
/**
* Reads a zig-zag encoded 64bit base 128 variable-length integer. Requires Long.js.
* @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
* read if omitted.
* @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and
* the actual number of bytes read.
* @throws {Error} If it's not a valid varint
* @expose
*/
ByteBufferPrototype.readVarint64ZigZag = function(offset) {
var val = this.readVarint64(offset);
if (val && val['value'] instanceof Long)
val["value"] = ByteBuffer.zigZagDecode64(val["value"]);
else
val = ByteBuffer.zigZagDecode64(val);
return val;
};
} // Long
//? }

50
node_modules/bytebuffer/src/wrap-node.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
/*
Copyright 2013-2014 Daniel Wirtz <dcode@dcode.io>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
//? NODE = true;
/**
* @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
* Backing buffer / Accessor: node Buffer
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/bytebuffer.js for details
*/
module.exports = (function() {
"use strict";
var buffer = require("buffer"),
Buffer = buffer["Buffer"],
Long = require("long"),
memcpy = null; try { memcpy = require("memcpy"); } catch (e) {}
//? include("ByteBuffer.js");
/**
* node-memcpy. This is an optional binding dependency and may not be present.
* @function
* @param {!(Buffer|ArrayBuffer|Uint8Array)} target Destination
* @param {number|!(Buffer|ArrayBuffer)} targetStart Destination start, defaults to 0.
* @param {(!(Buffer|ArrayBuffer|Uint8Array)|number)=} source Source
* @param {number=} sourceStart Source start, defaults to 0.
* @param {number=} sourceEnd Source end, defaults to capacity.
* @returns {number} Number of bytes copied
* @throws {Error} If any index is out of bounds
* @expose
*/
ByteBuffer.memcpy = memcpy;
return ByteBuffer;
})();

43
node_modules/bytebuffer/src/wrap.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright 2013-2014 Daniel Wirtz <dcode@dcode.io>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
//? if (DATAVIEW)
* Backing buffer: ArrayBuffer, Accessor: DataView
//? else
* Backing buffer: ArrayBuffer, Accessor: Uint8Array
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/bytebuffer.js for details
*/
(function(global, factory) {
/* AMD */ if (typeof define === 'function' && define["amd"])
define(["long"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === "object" && module && module["exports"])
module['exports'] = (function() {
var Long; try { Long = require("long"); } catch (e) {}
return factory(Long);
})();
/* Global */ else
(global["dcodeIO"] = global["dcodeIO"] || {})["ByteBuffer"] = factory(global["dcodeIO"]["Long"]);
})(this, function(Long) {
"use strict";
//? include("bytebuffer.js");
return ByteBuffer;
});

99
node_modules/bytebuffer/tests/bench.js generated vendored Normal file
View File

@ -0,0 +1,99 @@
// a simple benchmark utility comparing performance between the different builds.
// Uint8Array observations (compared to node Buffers)
// - seems to be pretty much equal for byte ops
// DataView observations (compared to Uint8Array):
// - allocation is about 2 times slower
// - writing is about 5 times (int32) to 10 times (varint) slower
// - reading is about 3 times slower
// UTF8 encoding observations (compared to node's string/buffer API)
// - the longer the string, the poorer is read/write performance
// - either utfx doesn't cut it yet, or node's bindings simply outperform everything js here
var ByteBuffer = require("../index.js"),
prettyHrTime = require("pretty-hrtime");
var impls = [
{ name: "ByteBufferNB", impl: ByteBuffer.ByteBufferNB },
{ name: "ByteBufferAB", impl: ByteBuffer.ByteBufferAB },
{ name: "ByteBufferAB_DataView", impl: ByteBuffer.ByteBufferAB_DataView }
];
var bench = {};
bench["allocate"] = function(ByteBuffer, n) {
n = n || 10000;
for (var i=0; i<n; ++i)
new ByteBuffer();
return n;
};
bench["writeInt32"] = function(ByteBuffer, n) {
n = n || 1000000;
var bb = new ByteBuffer(4);
for (var i=0; i<n; ++i)
bb.writeInt32(0x7fffffff, 0);
return n;
};
bench["readInt32"] = function(ByteBuffer, n) {
n = n || 1000000;
var bb = new ByteBuffer(4).writeInt32(0x7fffffff).flip();
for (var i=0; i<n; ++i)
bb.readInt32(0);
return n;
};
bench["writeVarint32"] = function(ByteBuffer, n) {
n = n || 1000000;
var bb = new ByteBuffer(6);
for (var i=0; i<n; ++i)
bb.writeVarint32(0x7fffffff, 0);
return n;
};
bench["readVarint32"] = function(ByteBuffer, n) {
n = n || 1000000;
var bb = new ByteBuffer(6).writeInt32(0x7fffffff).flip();
for (var i=0; i<n; ++i)
bb.readVarint32(0);
return n;
};
bench["writeString"] = function(ByteBuffer, n) {
n = n || 100000;
var bb = new ByteBuffer(26);
for (var i=0; i<n; ++i)
bb.writeString("abcdefghijklmnopqrstuvwxyz", 0);
return n;
};
bench["readString"] = function(ByteBuffer, n) {
n = n || 100000;
var bb = new ByteBuffer(26).writeString("abcdefghijklmnopqrstuvwxyz").flip();
for (var i=0; i<n; ++i)
bb.readString(26, ByteBuffer.METRICS_BYTES, 0);
return n;
};
bench["calculateString"] = function(ByteBuffer, n) {
n = n || 100000;
for (var i=0; i<n; ++i)
ByteBuffer.calculateString("abcdefghijklmnopqrstuvwxyz");
return n;
};
Object.keys(bench).forEach(function(key) {
var func = bench[key];
console.log(key);
impls.forEach(function(impl) {
var n, diff;
var start = process.hrtime();
n = func(impl.impl);
diff = process.hrtime(start);
console.log("- "+impl.name+": "+prettyHrTime(diff));
});
console.log();
});

1005
node_modules/bytebuffer/tests/suite.js generated vendored Normal file

File diff suppressed because it is too large Load Diff