@socketsupply/ltp
Advanced tools
Comparing version 2.0.1 to 2.0.2
13
any.js
var {isArray} = Array | ||
//en/decode a collection of types, | ||
@@ -15,2 +15,9 @@ //every type must have a type field in the same place | ||
//verify that every item has type/length | ||
if(!isArray(codex)) { | ||
var obj = codex | ||
codex = [] | ||
for(var k in obj) | ||
codex.push(obj[k]) | ||
} | ||
var map = {}, nameMap = {} | ||
@@ -47,2 +54,6 @@ var type_position | ||
decodeType, | ||
decodeTypeName: function (buffer, start, end) { | ||
var type = decodeType(buffer, start, end) | ||
return nameMap[type] | ||
}, | ||
decode: function (buffer, start=0, end=buffer.length) { | ||
@@ -49,0 +60,0 @@ var tvalue = decodeType(buffer, start, end) |
@@ -65,3 +65,3 @@ 'use strict' | ||
decode.bytes = value+(length_field.offset|0) | ||
var _end = start + value | ||
var _end = start + decode.bytes | ||
if(_end > end) throw new Error('length field out of bounds') | ||
@@ -68,0 +68,0 @@ //but a smaller value for end is acceptable. |
{ | ||
"name": "@socketsupply/ltp", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A schemaful parseless binary format, like a simpler version of captnproto. fast access to fields without allocating memory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -174,3 +174,3 @@ var codex = require('./codex') | ||
//TODO XXX end is not big enough to contain: start + position + direct.bytes | ||
throw new Error('direct value out of bounds? :'+test+JSON.stringify({direct, start, position, end, test})) | ||
throw new Error('direct value out of bounds? attempted to read '+direct.type+' at:'+ (start+position) + '(position:'+position+') end was:'+ end) | ||
} | ||
@@ -177,0 +177,0 @@ |
130307
1607