Skip to content

Commit ac00eff

Browse files
committed
ByteBuffer.js 3, initial commit
1 parent 708afa4 commit ac00eff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+21327
-9899
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
npm-debug.log
3+
.idea/

ByteBuffer.js

Lines changed: 0 additions & 2320 deletions
This file was deleted.

ByteBuffer.min.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

ByteBuffer.min.map

Lines changed: 0 additions & 8 deletions
This file was deleted.

ByteBuffer.noexpose.js

Lines changed: 0 additions & 2207 deletions
This file was deleted.

README.md

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1-
![ByteBuffer.js - A full-featured ByteBuffer implementation in JavaScript](https://raw.github.com/dcodeIO/ByteBuffer.js/master/ByteBuffer.png)
1+
![ByteBuffer.js - A full-featured and highly optimized ByteBuffer in JavaScript](https://raw.github.com/dcodeIO/ByteBuffer.js/master/ByteBuffer.png)
22
======================================
3-
Provides a full-featured ByteBuffer implementation using typed arrays. It's one of the core components driving
4-
[ProtoBuf.js](https://github.com/dcodeIO/ProtoBuf.js) and the [PSON](https://github.com/dcodeIO/PSON) reference
5-
implementation.
3+
ByteBuffer.js provides a full-featured and highly optimized ByteBuffer implementation in JavaScript, since version 3
4+
either backed by an ArrayBuffer for browser environments (ByteBufferAB) or, alternatively, a node Buffer (ByteBufferNB)
5+
to make use of the performance benefits when running under node.js. Both versions are API-compatible and generated from
6+
a single source tree using [MetaScript](https://github.com/dcodeIO/MetaScript).
67

7-
*Note:* The API behind #toHex and #toString has changed with ByteBuffer 2, which is a generally revised release, in
8-
favor of making this more intuitive.
8+
If you are looking for ByteBuffer.js 2, [that's the branch](https://github.com/dcodeIO/ByteBuffer.js/tree/ByteBuffer2).
9+
10+
**Please note**: Though all old and new test cases are passing, ByteBuffer.js 3 still needs to be tested in real world
11+
scenarios. Also, the API has changed a bit to make things more straight forward.
912

1013
What can it do?
1114
---------------
1215
* Mimics Java ByteBuffers as close as reasonable while using typed array terms
13-
* Signed and unsigned integers (8, 16, 32, 64 bit through [Long.js](https://github.com/dcodeIO/Long.js)) with endianness support
16+
* 8, 16, 32 and 64 bit signed and unsigned integers
1417
* 32 and 64 bit floats
15-
* Varints as known from protobuf including zig-zag encoding
16-
* Includes an UTF8 and Base64 en-/decoder
17-
* C-strings, V(arint-prefixed)-strings and UTF8 L(ength-prefixed)-strings
18-
* Rich string toolset (to hex, base64, binary, utf8, debug, columns)
19-
* Relative and absolute zero-copy operations
18+
* Big and little endianness
19+
* Variable length integers as used in protobuf (32 and 64 bit, including zig zag encoding)
20+
* Base64, binary, debug, hex and utf8 encodings
21+
* Handy string and debugging utilities
22+
* Relative and absolute zero-copy operations wherever possible
2023
* Manual and automatic resizing (efficiently doubles capacity)
2124
* Chaining of all operations that do not return a specific value
2225
* Slicing, appending, prepending, reversing, flip, mark, reset, etc.
2326

24-
And much more...
25-
26-
Features
27-
--------
28-
* [CommonJS](http://www.commonjs.org/) compatible
29-
* [RequireJS](http://requirejs.org/)/AMD compatible
30-
* [node.js](http://nodejs.org) compatible, also available via [npm](https://npmjs.org/package/bytebuffer)
31-
* Browser compatible
32-
* [Closure Compiler](https://developers.google.com/closure/compiler/) ADVANCED_OPTIMIZATIONS compatible (fully annotated,
33-
`ByteBuffer.min.js` has been compiled this way, `ByteBuffer.min.map` is the source map)
27+
More
28+
----
29+
* CommonJS, AMD and shim compatible
30+
* Also available via [npm](https://npmjs.org/package/bytebuffer)
31+
* Compiled through [Closure Compiler](https://developers.google.com/closure/compiler/) using ADVANCED_OPTIMIZATIONS
32+
(fully annotated, includes externs and source map)
3433
* Fully documented using [jsdoc3](https://github.com/jsdoc3/jsdoc)
35-
* Well tested through [nodeunit](https://github.com/caolan/nodeunit)
34+
* Well tested through [test.js](https://github.com/dcodeIO/test.js)
3635
* Zero production dependencies (Long.js is optional)
37-
* Small footprint
3836

3937
Usage
4038
-----
41-
### Node.js / CommonJS ###
39+
### Node.js ###
4240
* Install: `npm install bytebuffer`
4341

4442
```javascript
4543
var ByteBuffer = require("bytebuffer");
4644
var bb = new ByteBuffer();
47-
bb.writeLString("Hello world!").flip();
48-
console.log(bb.readLString()+" from ByteBuffer.js");
45+
bb.writeIString("Hello world!").flip();
46+
console.log(bb.readIString()+" from ByteBuffer.js");
4947
```
5048

5149
### Browser ###
@@ -61,11 +59,11 @@ support, you can skip the Long.js include.
6159
```javascript
6260
var ByteBuffer = dcodeIO.ByteBuffer;
6361
var bb = new ByteBuffer();
64-
bb.writeLString("Hello world!").flip();
65-
alert(bb.readLString()+" from ByteBuffer.js");
62+
bb.writeIString("Hello world!").flip();
63+
alert(bb.readIString()+" from ByteBuffer.js");
6664
```
6765

68-
### Require.js / AMD ###
66+
### AMD ###
6967

7068
Optionally depends on [Long.js](https://github.com/dcodeIO/Long.js) for long (int64) support. If you do not require long
7169
support, you can skip the Long.js config. [Require.js](http://requirejs.org/) example:
@@ -79,21 +77,11 @@ require.config({
7977
});
8078
require(["ByteBuffer"], function(ByteBuffer) {
8179
var bb = new ByteBuffer();
82-
bb.writeLString("Hello world!");
83-
bb.flip();
80+
bb.writeLString("Hello world!").flip();
8481
alert(bb.readLString()+" from ByteBuffer.js");
8582
});
8683
```
8784

88-
On long (int64) support
89-
-----------------------
90-
As of the [ECMAScript specification](http://ecma262-5.com/ELS5_HTML.htm#Section_8.5), number types have a maximum value
91-
of 2^53. Beyond that, behaviour might be unexpected. However, real long support requires the full 64 bits
92-
with the possibility to perform bitwise operations on the value for varint en-/decoding. So, to enable true long support
93-
in ByteBuffer.js, it optionally depends on [Long.js](https://github.com/dcodeIO/Long.js), which actually utilizes two
94-
32 bit numbers internally. If you do not require long support at all, you can skip it and save the additional bandwidth.
95-
On node, long support is available by default through the [long](https://npmjs.org/package/long) dependency.
96-
9785
Downloads
9886
---------
9987
* [ZIP-Archive](https://github.com/dcodeIO/ByteBuffer.js/archive/master.zip)

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bytebuffer",
3-
"version": "2.3.1",
3+
"version": "3.0.0-pre",
44
"author": "Daniel Wirtz <[email protected]>",
55
"description": "A full-featured ByteBuffer implementation using typed arrays.",
66
"main": "ByteBuffer.js",

build.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)