@@ -16,7 +16,7 @@ ByteBuffer
16
16
* Remaining readable bytes (` ByteBuffer#remaining() ` ) and backing buffer capacity getters (` ByteBuffer#capacity() ` )
17
17
* Explicit (` ByteBuffer#resize(capacity) ` ) and implicit resizing (` ByteBuffer#ensureCapacity(capacity) ` )
18
18
* Efficient implicit resizing by doubling the current capacity
19
- * Flipping (` ByteBuffer#flip() ` ) and resetting (` ByteBuffer#reset() ` ) like known from Java ByteBuffers
19
+ * Flipping (` ByteBuffer#flip() ` ), marking ( ` ByteBuffer#mark([offset]) ` ) and resetting (` ByteBuffer#reset() ` )
20
20
* Compacting of the backing buffer (` ByteBuffer#compact() ` )
21
21
* Conversion to ArrayBuffer (` ByteBuffer#toArrayBuffer([forceCopy]) ` ) (i.e. to send data over the wire, e.g. a WebSocket
22
22
with ` binaryType="arraybuffer" ` )
@@ -87,7 +87,11 @@ console.log(bb.readLString()+" from ByteBuffer.js");
87
87
88
88
### Browser (shim) ###
89
89
90
+ Optionally depends on [ Long.js] ( https://github.com/dcodeIO/Long.js ) for long (int64) support. If you do not require long
91
+ support, you can skip the Long.js include.
92
+
90
93
``` html
94
+ <script src =" //raw.github.com/dcodeIO/Long.js/master/Long.min.js" ></script >
91
95
<script src =" //raw.github.com/dcodeIO/ByteBuffer.js/master/ByteBuffer.min.js" ></script >
92
96
```
93
97
@@ -101,15 +105,33 @@ alert(bb.readLString()+" from ByteBuffer.js");
101
105
102
106
### Require.js / AMD ###
103
107
108
+ Optionally depends on [ Long.js] ( https://github.com/dcodeIO/Long.js ) for long (int64) support. If you do not require long
109
+ support, you can skip the Long.js config. [ Require.js] ( http://requirejs.org/ ) example:
110
+
104
111
``` javascript
105
- require ([" /path/to/ByteBuffer.js" ], function (ByteBuffer ) {
112
+ require .config ({
113
+ " paths" : {
114
+ " Long" : " /path/to/Long.js"
115
+ " ByteBuffer" : " /path/to/ByteBuffer.js"
116
+ }
117
+ });
118
+ require ([" ByteBuffer" ], function (ByteBuffer ) {
106
119
var bb = new ByteBuffer ();
107
120
bb .writeLString (" Hello world!" );
108
121
bb .flip ();
109
122
alert (bb .readLString ()+ " from ByteBuffer.js" );
110
123
});
111
124
```
112
125
126
+ On long (int64) support
127
+ -----------------------
128
+ As of the [ ECMAScript specification] ( http://ecma262-5.com/ELS5_HTML.htm#Section_8.5 ) , number types have a maximum value
129
+ of 2^53. Beyond that, JavaScript falls back to double internally. However, real long support requires the full 64 bits
130
+ with the possibility to perform bitwise operations on the value for varint en-/decoding. So, to enable true long support
131
+ in ByteBuffer.js, it optionally depends on [ Long.js] ( https://github.com/dcodeIO/Long.js ) , which actually utilizes two
132
+ 32 bit numbers internally. If you do not require long support at all, you can skip it and save the additional bandwidth.
133
+ On node, long support is available by default through the [ long] ( https://npmjs.org/package/long ) dependency.
134
+
113
135
Downloads
114
136
---------
115
137
* [ ZIP-Archive] ( https://github.com/dcodeIO/ByteBuffer.js/archive/master.zip )
0 commit comments