Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow to unpack from a specific position in a buff

  • Loading branch information...
commit 2fa7aa51fd70564aa05054dc574917f9bd279f46 1 parent cdf519f
@tjfontaine authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 struct.js
View
11 struct.js
@@ -155,7 +155,9 @@ var fmt_to_list = function(fmt, prefix) {
return result;
};
-var unpack = function(fmt, input, encoding) {
+var unpack = function(fmt, input, encoding, pos) {
+ var calls, result = [];
+
if (!Buffer.isBuffer(input)) {
throw new Error("Input not a buffer object");
}
@@ -164,10 +166,11 @@ var unpack = function(fmt, input, encoding) {
encoding = 'ascii';
}
- var calls = fmt_to_list(fmt, 'read');
+ calls = fmt_to_list(fmt, 'read');
- var result = [];
- var pos = 0;
+ if (pos === undefined) {
+ pos = 0;
+ }
calls.forEach(function(c) {
var i;
Please sign in to comment.
Something went wrong with that request. Please try again.