Comparing version 0.2.0 to 0.2.1
22
ctype.js
@@ -521,3 +521,3 @@ /* | ||
else if (dispatch == 'write') | ||
return (this.readStruct(value, this.types[type], | ||
return (this.writeStruct(value, this.types[type], | ||
buffer, offset)); | ||
@@ -697,3 +697,3 @@ else | ||
ret = this.writeArray(value, type['type'], | ||
len, buffer, offset); | ||
buffer, offset); | ||
} else { | ||
@@ -714,3 +714,3 @@ if (type['type'] in deftypes) | ||
*/ | ||
CTypeParser.prototype.writeStruct = function (def, buffer, offset) | ||
CTypeParser.prototype.writeStruct = function (value, def, buffer, offset) | ||
{ | ||
@@ -730,5 +730,5 @@ var ii, entry, type, key; | ||
offset += this.writeEntry(entry['value'], type, buffer, offset); | ||
offset += this.writeEntry(value[ii], type, buffer, offset); | ||
/* Now that we've written it out, we can use it for arrays */ | ||
/* Keep track of types for array length resolution */ | ||
vals[key] = entry['value']; | ||
@@ -748,5 +748,9 @@ } | ||
* offset The offset in the buffer to write to | ||
* | ||
* TODO This endpoint really is just awful. See ticket CTYPE-6 | ||
*/ | ||
CTypeParser.prototype.writeData = function (def, buffer, offset) | ||
{ | ||
var ii, vals, key; | ||
if (def === undefined) | ||
@@ -765,4 +769,8 @@ throw (new Error('missing definition for what we should be' + | ||
ctCheckReq(def, this.types, [ 'value' ]); | ||
this.writeStruct(def, buffer, offset); | ||
vals = []; | ||
for (ii = 0; ii < def.length; ii++) { | ||
key = Object.keys(def[ii])[0]; | ||
vals.push(def[ii][key]['value']); | ||
} | ||
this.writeStruct(vals, def, buffer, offset); | ||
}; | ||
@@ -769,0 +777,0 @@ |
{ | ||
"name": "ctype", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "read and write binary structures and data types", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/rmustacc/node-ctype", |
Sorry, the diff of this file is not supported yet
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
175944
4308