diffusion
Advanced tools
Comparing version 5.7.8 to 5.7.9
{ | ||
"name": "diffusion", | ||
"version": "5.7.8", | ||
"version": "5.7.9", | ||
"description": "Diffusion Javascript UCI client", | ||
@@ -18,3 +18,3 @@ "keywords" : ["diffusion", "reappt", "websockets", "data"], | ||
"inherits" : "2.0.1", | ||
"hashmap" : "2.0.3", | ||
"hashmap" : "2.0.6", | ||
"long" : "2.2.5", | ||
@@ -21,0 +21,0 @@ "loglevel" : "1.4.0", |
@@ -29,5 +29,5 @@ var SessionImpl = require('session/session-impl'); | ||
*/ | ||
version : '5.7.8', | ||
version : '5.7.9', | ||
build : '8_01#42172', | ||
build : '9_01#44204', | ||
@@ -34,0 +34,0 @@ /** |
@@ -26,8 +26,9 @@ module.exports.types = { | ||
module.exports.tokens = { | ||
ARRAY_START : '[', | ||
ARRAY_END : ']', | ||
MAP_START : '{', | ||
MAP_END : '}', | ||
FIELD : '&', | ||
VALUE : '*' | ||
ARRAY_START : 0, | ||
ARRAY_END : 1, | ||
MAP_START : 2, | ||
MAP_END : 3, | ||
STRING_START : 4, | ||
STRING_END : 5, | ||
VALUE : 6 | ||
}; |
var Tokeniser = require('cbor/tokeniser'); | ||
var tokens = require('cbor/consts').tokens; | ||
var consts = require('cbor/consts'); | ||
var tokens = consts.tokens, | ||
types = consts.types; | ||
// Recursive token-parsing function; will evaluate tokens and build up complete object representations in order. | ||
/*jshint maxcomplexity:20 */ | ||
function decode(token, tokeniser) { | ||
@@ -29,3 +33,3 @@ switch (token.type) { | ||
obj[field.value] = decode(value, tokeniser); | ||
obj[decode(field, tokeniser)] = decode(value, tokeniser); | ||
} | ||
@@ -52,2 +56,34 @@ | ||
return arr; | ||
case tokens.STRING_START : | ||
var chunks = []; | ||
while (true) { | ||
var chunk = tokeniser.nextToken(); | ||
if (chunk === null) { | ||
throw new Error('Unexpected EOF (reading: indefinite-length string'); | ||
} | ||
if (chunk.type === tokens.STRING_END) { | ||
break; | ||
} | ||
if (chunk.header.type !== token.header.type) { | ||
throw new Error('Unexpected chunk type (' + chunk.header.type + ') within string'); | ||
} | ||
chunks.push(chunk.value); | ||
} | ||
var joined; | ||
if (token.header.type === types.BYTES) { | ||
joined = Buffer.concat(chunks); | ||
} | ||
if (token.header.type === types.STRING) { | ||
joined = chunks.join(''); | ||
} | ||
return joined; | ||
default : | ||
@@ -54,0 +90,0 @@ throw new Error('Unexpected token: ' + JSON.stringify(token)); |
@@ -13,3 +13,11 @@ var Context = require('./context'); | ||
function isValueToken(t) { | ||
return t === tokens.VALUE || t === tokens.MAP_END || t === tokens.ARRAY_END; | ||
switch (t) { | ||
case tokens.VALUE: | ||
case tokens.MAP_END: | ||
case tokens.ARRAY_END: | ||
case tokens.STRING_END: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
@@ -50,3 +58,3 @@ | ||
if (ctx === 'object' || ctx === 'array') { | ||
if (ctx !== 'root') { | ||
// If the previous token was a value (either scalar or a collection), update the current context | ||
@@ -58,3 +66,14 @@ if (context.remaining() && isValueToken(token)) { | ||
if (!context.remaining()) { | ||
token = (ctx === 'object' ? tokens.MAP_END : tokens.ARRAY_END); | ||
switch (ctx) { | ||
case 'object' : | ||
token = tokens.MAP_END; | ||
break; | ||
case 'array' : | ||
token = tokens.ARRAY_END; | ||
break; | ||
case 'string' : | ||
token = tokens.STRING_END; | ||
break; | ||
} | ||
context.pop(); | ||
@@ -77,13 +96,17 @@ | ||
case types.FLOAT : | ||
case types.SIMPLE : | ||
token = tokens.VALUE; | ||
value = readValue(header); | ||
break; | ||
case types.BYTES : | ||
case types.STRING : | ||
case types.SIMPLE : | ||
// If we're in an object, flip-flop between fields/values | ||
if (ctx === 'object' && token !== tokens.FIELD) { | ||
token = tokens.FIELD; | ||
// Handle indefinite length strings: https://tools.ietf.org/html/rfc7049#section-2.2.2 | ||
if (header.raw === additional.BREAK) { | ||
context.push('string', -1); | ||
token = tokens.STRING_START; | ||
} else { | ||
token = tokens.VALUE; | ||
value = readValue(header); | ||
} | ||
value = readValue(header); | ||
break; | ||
@@ -95,3 +118,10 @@ case types.ARRAY : | ||
case types.MAP : | ||
context.push('object', readCollectionLength(header)); | ||
var len = readCollectionLength(header); | ||
// Length specifies how many entries; we need to count keys/values separately | ||
if (len >= 0) { | ||
len = len * 2; | ||
} | ||
context.push('object', len); | ||
token = tokens.MAP_START; | ||
@@ -115,3 +145,4 @@ break; | ||
type : token, | ||
value : value | ||
value : value, | ||
header : header | ||
}; | ||
@@ -118,0 +149,0 @@ }; |
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
488147
13558
+ Addedhashmap@2.0.6(transitive)
- Removedhashmap@2.0.3(transitive)
Updatedhashmap@2.0.6