Permalink
Browse files

allow to unpack from a specific position in a buff

  • Loading branch information...
1 parent cdf519f commit 2fa7aa51fd70564aa05054dc574917f9bd279f46 @tjfontaine committed Sep 18, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 struct.js
View
@@ -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;

0 comments on commit 2fa7aa5

Please sign in to comment.