Comparing version 0.2.3 to 0.2.4
@@ -5,4 +5,63 @@ var ProtoDef = require("protodef").ProtoDef; | ||
// the protocol can be in a separate json file | ||
var example_protocol={ | ||
"container": "native", | ||
"varint": "native", | ||
"byte": "native", | ||
"bool": "native", | ||
"switch": "native", | ||
"entity_look": [ | ||
"container", | ||
[ | ||
{ | ||
"name": "entityId", | ||
"type": "varint" | ||
}, | ||
{ | ||
"name": "yaw", | ||
"type": "byte" | ||
}, | ||
{ | ||
"name": "pitch", | ||
"type": "byte" | ||
}, | ||
{ | ||
"name": "onGround", | ||
"type": "bool" | ||
} | ||
] | ||
], | ||
"packet": [ | ||
"container", | ||
[ | ||
{ | ||
"name": "name", | ||
"type": [ | ||
"mapper", | ||
{ | ||
"type": "varint", | ||
"mappings": { | ||
"22": "entity_look" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "params", | ||
"type": [ | ||
"switch", | ||
{ | ||
"compareTo": "name", | ||
"fields": { | ||
"entity_look": "entity_look" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
] | ||
}; | ||
var proto = new ProtoDef(); | ||
proto.addTypes(require("./example_protocol.json").types); | ||
proto.addTypes(example_protocol); | ||
var parser = new Parser(proto, "packet"); | ||
@@ -9,0 +68,0 @@ var serializer = new Serializer(proto, "packet"); |
{ | ||
"name": "protodef", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A simple yet powerful way to define binary protocols", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -114,2 +114,5 @@ # ProtoDef | ||
### 0.2.4 | ||
* get back the example file as one file for simplicity and for tonic | ||
### 0.2.3 | ||
@@ -116,0 +119,0 @@ * fix a small mistake in mapping error |
@@ -19,4 +19,62 @@ var ITERATIONS = 100000; | ||
proto.addTypes(require("../example_protocol.json").types); | ||
var example_protocol={ | ||
"container": "native", | ||
"varint": "native", | ||
"byte": "native", | ||
"bool": "native", | ||
"switch": "native", | ||
"entity_look": [ | ||
"container", | ||
[ | ||
{ | ||
"name": "entityId", | ||
"type": "varint" | ||
}, | ||
{ | ||
"name": "yaw", | ||
"type": "byte" | ||
}, | ||
{ | ||
"name": "pitch", | ||
"type": "byte" | ||
}, | ||
{ | ||
"name": "onGround", | ||
"type": "bool" | ||
} | ||
] | ||
], | ||
"packet": [ | ||
"container", | ||
[ | ||
{ | ||
"name": "name", | ||
"type": [ | ||
"mapper", | ||
{ | ||
"type": "varint", | ||
"mappings": { | ||
"22": "entity_look" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "params", | ||
"type": [ | ||
"switch", | ||
{ | ||
"compareTo": "name", | ||
"fields": { | ||
"entity_look": "entity_look" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
] | ||
}; | ||
proto.addTypes(example_protocol); | ||
describe("benchmark",function(){ | ||
@@ -23,0 +81,0 @@ this.timeout(60 * 1000); |
190748
2167
146
48