binary-parser
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "binary-parser", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Blazing-fast binary parser builder", | ||
@@ -5,0 +5,0 @@ "main": "lib/binary_parser.js", |
# Binary-parser | ||
[![Build Status](https://travis-ci.org/Keichi/binary-parser.png?branch=master)](https://travis-ci.org/Keichi/binary-parser) | ||
[![Build Status](https://api.shippable.com/projects/540e7af73479c5ea8f9ebc33/badge?branchName=master)](https://app.shippable.com/projects/540e7af73479c5ea8f9ebc33/builds/latest) | ||
@@ -96,3 +96,3 @@ Binary-parser is a binary parser builder library for [node](http://nodejs.org), | ||
.int32le('a') | ||
// Unsigned 8-bit integer (little/big endian) | ||
// Unsigned 8-bit integer | ||
.uint8('b') | ||
@@ -112,2 +112,10 @@ // Signed 16-bit integer (big endian) | ||
```javascript | ||
var parser = new Parser() | ||
// 32-bit floating value (big endian) | ||
.floatbe('a') | ||
// 64-bit floating value (little endian) | ||
.doublele('b') | ||
``` | ||
### string(name [,options]) | ||
@@ -114,0 +122,0 @@ Parse bytes as a string. `name` should consist only of alpha numeric characters and start |
@@ -13,3 +13,3 @@ var assert = require('assert'); | ||
}); | ||
it('should parse primitive types', function(){ | ||
it('should parse integer types', function(){ | ||
var parser = | ||
@@ -24,2 +24,18 @@ Parser.start() | ||
}); | ||
it('should parse floating point types', function(){ | ||
var parser = | ||
Parser.start() | ||
.floatbe('a') | ||
.doublele('b'); | ||
var FLT_EPSILON = 0.00001 | ||
var buffer = new Buffer([ | ||
0x41, 0x45, 0x85, 0x1f, | ||
0x7a, 0x36, 0xab, 0x3e, 0x57, 0x5b, 0xb1, 0xbf | ||
]); | ||
var result = parser.parse(buffer); | ||
assert(Math.abs(result.a - 12.345) < FLT_EPSILON); | ||
assert(Math.abs(result.b - (-0.0678)) < FLT_EPSILON); | ||
}); | ||
it('should handle endianess', function(){ | ||
@@ -26,0 +42,0 @@ var parser = |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105766
1274
304