diffusion
Advanced tools
Comparing version 5.8.3 to 5.8.4
{ | ||
"name": "diffusion", | ||
"version": "5.8.3", | ||
"version": "5.8.4", | ||
"description": "Diffusion Javascript UCI client", | ||
@@ -5,0 +5,0 @@ "keywords" : ["diffusion", "reappt", "websockets", "data"], |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
var RecordContent = interface('RecordContent', [ | ||
var RecordContent = _interface('RecordContent', [ | ||
/** | ||
@@ -120,3 +120,3 @@ * Get a record for a given name and index. If the specified record doesn't | ||
*/ | ||
RecordContent.Record = interface('Record', [ | ||
RecordContent.Record = _interface('Record', [ | ||
/** | ||
@@ -203,3 +203,3 @@ * Get the value for a given field name. An optional index may be provided if the metadata allows for multiple | ||
*/ | ||
RecordContent.Builder = interface('RecordContentBuilder', [ | ||
RecordContent.Builder = _interface('RecordContentBuilder', [ | ||
/** | ||
@@ -313,3 +313,3 @@ * Add a new record with a given name. Field values can be provided as an object of key/value pairs. If the metadata | ||
*/ | ||
RecordContent.Builder.Record = interface('RecordContentRecordBuilder', [ | ||
RecordContent.Builder.Record = _interface('RecordContentRecordBuilder', [ | ||
/** | ||
@@ -316,0 +316,0 @@ * Add a field value for a given name. If the associated metadata allows multiple fields, this will |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var DataType = require('../datatype'); | ||
@@ -22,3 +22,3 @@ | ||
*/ | ||
module.exports = interface('BinaryDataType', DataType, [ | ||
module.exports = _interface('BinaryDataType', DataType, [ | ||
/** | ||
@@ -25,0 +25,0 @@ * Returns a new {@link DataTypes.Binary} instance from a buffer. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
module.exports = interface('BinaryDelta', [ | ||
module.exports = _interface('BinaryDelta', [ | ||
/** | ||
@@ -12,0 +12,0 @@ * Whether this delta contains any changes. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Bytes = require('../bytes'); | ||
@@ -17,3 +17,3 @@ | ||
*/ | ||
module.exports = interface('Binary', Bytes, [ | ||
module.exports = _interface('Binary', Bytes, [ | ||
/** | ||
@@ -20,0 +20,0 @@ * Get the value as a Buffer. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
module.exports = interface('Bytes', [ | ||
module.exports = _interface('Bytes', [ | ||
/** | ||
@@ -19,0 +19,0 @@ * @return {Number} The length of the data in bytes |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
module.exports = interface('DataType', [ | ||
module.exports = _interface('DataType', [ | ||
/** | ||
@@ -22,0 +22,0 @@ * The external type identifier. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
module.exports = interface('DataTypes', [ | ||
module.exports = _interface('DataTypes', [ | ||
/** | ||
@@ -22,0 +22,0 @@ * @return {DataTypes.BinaryDataType} The Binary data type |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
module.exports = interface('DeltaType', [ | ||
module.exports = _interface('DeltaType', [ | ||
@@ -22,0 +22,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var DataType = require('../datatype'); | ||
@@ -22,3 +22,3 @@ | ||
*/ | ||
module.exports = interface('JSONDataType', DataType, [ | ||
module.exports = _interface('JSONDataType', DataType, [ | ||
@@ -25,0 +25,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Bytes = require('../bytes'); | ||
@@ -41,3 +41,3 @@ | ||
*/ | ||
module.exports = interface('JSON', Bytes, [ | ||
module.exports = _interface('JSON', Bytes, [ | ||
@@ -44,0 +44,0 @@ /** |
@@ -29,5 +29,5 @@ var SessionImpl = require('session/session-impl'); | ||
*/ | ||
version : '5.8.3', | ||
version : '5.8.4', | ||
build : '3_dev#internal', | ||
build : '4_dev#internal', | ||
@@ -34,0 +34,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -11,4 +11,4 @@ /** | ||
*/ | ||
var ErrorReport = interface('ErrorReport', ['message', 'line', 'column']); | ||
var ErrorReport = _interface('ErrorReport', ['message', 'line', 'column']); | ||
module.exports = ErrorReport; |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Stream = require('./stream'); | ||
@@ -62,22 +62,4 @@ | ||
*/ | ||
module.exports = interface('FetchStream', Stream, [ | ||
/** | ||
* Produce a {@link TypedFetchStream} from this fetch stream, in order to receive values as a particular | ||
* {@link DataType}. The {@link TypedFetchStream} will only emit values from topics that are of matching type | ||
* for the provided data type. | ||
* | ||
* @param {DataType} datatype - The data type to produce a stream for | ||
* @returns {TypedFetchStream} A new Typed FetchStream for the provided data type | ||
* | ||
* @example | ||
* // Fetch a stream of JSON values | ||
* var datatype = diffusion.datatypes.json(); | ||
* | ||
* session.fetch("foo").asType(datatype).on('value', function(value, topicPath) { | ||
* console.log(value.get()); | ||
* }); | ||
* | ||
* @function FetchStream#asType | ||
*/ | ||
'asType' | ||
module.exports = _interface('FetchStream', Stream, [ | ||
]); |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
module.exports = interface('Result', [ | ||
module.exports = _interface('Result', [ | ||
/** | ||
@@ -12,0 +12,0 @@ * Chain a Result. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
module.exports = interface('Stream', [ | ||
module.exports = _interface('Stream', [ | ||
/** | ||
@@ -21,0 +21,0 @@ * Register listeners against events. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Stream = require('./stream'); | ||
@@ -101,3 +101,3 @@ | ||
*/ | ||
module.exports = interface('Subscription', Stream, [ | ||
module.exports = _interface('Subscription', Stream, [ | ||
/** | ||
@@ -104,0 +104,0 @@ * A static reference to the selector this Subscription was created for. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Stream = require('./stream'); | ||
@@ -95,3 +95,3 @@ | ||
*/ | ||
module.exports = interface('TypedSubscription', Stream, [ | ||
module.exports = _interface('TypedSubscription', Stream, [ | ||
/** | ||
@@ -98,0 +98,0 @@ * A static reference to the selector this Subscription was created for. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Stream = require('./stream'); | ||
@@ -36,3 +36,3 @@ | ||
*/ | ||
module.exports = interface('View', Stream, [ | ||
module.exports = _interface('View', Stream, [ | ||
/** | ||
@@ -39,0 +39,0 @@ * Returns a read-only version of the the view's current state. This will |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -14,3 +14,3 @@ /** | ||
var ClientControl = interface('ClientControl', [ | ||
var ClientControl = _interface('ClientControl', [ | ||
/** | ||
@@ -171,3 +171,3 @@ * Query the server for property values of a specified client session. | ||
*/ | ||
ClientControl.SessionPropertiesListener = interface('SessionPropertiesListener', [ | ||
ClientControl.SessionPropertiesListener = _interface('SessionPropertiesListener', [ | ||
/** | ||
@@ -174,0 +174,0 @@ * Called when the listener has been registered at the server and is now active. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
/** | ||
@@ -14,3 +14,3 @@ * Messages Feature. | ||
*/ | ||
var Messages = interface('Messaging', [ | ||
var Messages = _interface('Messaging', [ | ||
/** | ||
@@ -89,3 +89,3 @@ * Send an arbitrary message to either the server or another session, on a particular path. | ||
* sessions for a particular path but with no specified recipient. The handler must implement the | ||
* {@link Session.messages.MessageHandler MessageHandler} interface. | ||
* {@link Session.messages.MessageHandler MessageHandler} _interface. | ||
* <P> | ||
@@ -155,3 +155,3 @@ * <br /> | ||
*/ | ||
Messages.MessageStream = interface('MessageStream'); | ||
Messages.MessageStream = _interface('MessageStream'); | ||
@@ -171,3 +171,3 @@ /** | ||
*/ | ||
Messages.MessageHandler = interface('MessageHandler', [ | ||
Messages.MessageHandler = _interface('MessageHandler', [ | ||
/** | ||
@@ -174,0 +174,0 @@ * Handle a message that was sent by another Session to the server, on a path that is a descendant of the path |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -20,3 +20,3 @@ /** | ||
*/ | ||
var SystemPrincipal = interface('SystemPrincipal', ['name', 'roles']); | ||
var SystemPrincipal = _interface('SystemPrincipal', ['name', 'roles']); | ||
@@ -90,3 +90,3 @@ /** | ||
*/ | ||
var Role = interface('Role', ['name', 'global', 'default', 'topic', 'inherits']); | ||
var Role = _interface('Role', ['name', 'global', 'default', 'topic', 'inherits']); | ||
@@ -101,3 +101,3 @@ /** | ||
*/ | ||
var SecurityConfiguration = interface('SecurityConfiguration', ['named', 'anonymous', 'roles']); | ||
var SecurityConfiguration = _interface('SecurityConfiguration', ['named', 'anonymous', 'roles']); | ||
@@ -121,3 +121,3 @@ /** | ||
*/ | ||
var SystemAuthenticationConfiguration = interface('SystemAuthenticationConfiguration', ['principals', 'anonymous']); | ||
var SystemAuthenticationConfiguration = _interface('SystemAuthenticationConfiguration', ['principals', 'anonymous']); | ||
@@ -131,3 +131,3 @@ /** | ||
*/ | ||
var SecurityScriptBuilder = interface('SecurityScriptBuilder', [ | ||
var SecurityScriptBuilder = _interface('SecurityScriptBuilder', [ | ||
/** | ||
@@ -246,3 +246,3 @@ * Create the script string. | ||
*/ | ||
var SystemAuthenticationScriptBuilder = interface('SystemAuthenticationScriptBuilder', [ | ||
var SystemAuthenticationScriptBuilder = _interface('SystemAuthenticationScriptBuilder', [ | ||
/** | ||
@@ -344,3 +344,3 @@ * Create the script string. | ||
var Security = interface('Security', [ | ||
var Security = _interface('Security', [ | ||
/** | ||
@@ -347,0 +347,0 @@ * Get the principal that the session is currently authenticated as. |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -15,3 +15,3 @@ /** | ||
module.exports.TopicControl = interface('TopicControl', [ | ||
module.exports.TopicControl = _interface('TopicControl', [ | ||
/** | ||
@@ -381,3 +381,3 @@ * Add a topic to the server at a specific path. This returns a {@link Result}. | ||
*/ | ||
module.exports.MissingTopicHandler = interface('MissingTopicHandler', [ | ||
module.exports.MissingTopicHandler = _interface('MissingTopicHandler', [ | ||
/** | ||
@@ -465,3 +465,3 @@ * Called when a client session requests a topic that does not exist, | ||
*/ | ||
module.exports.MissingTopicNotification = interface('MissingTopicNotification', [ | ||
module.exports.MissingTopicNotification = _interface('MissingTopicNotification', [ | ||
/** | ||
@@ -528,3 +528,3 @@ * @property {String} The common root topic path derived from the requested topic selector | ||
*/ | ||
module.exports.TopicUpdateHandler = interface('TopicUpdateHandler', [ | ||
module.exports.TopicUpdateHandler = _interface('TopicUpdateHandler', [ | ||
/** | ||
@@ -604,3 +604,3 @@ * Called when the handler has been successfully registered with the server. | ||
*/ | ||
module.exports.Updater = interface('Updater', [ | ||
module.exports.Updater = _interface('Updater', [ | ||
/** | ||
@@ -607,0 +607,0 @@ * Update a topic |
@@ -1,4 +0,4 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
var Topics = interface('Topics', [ | ||
var Topics = _interface('Topics', [ | ||
/** | ||
@@ -187,3 +187,3 @@ * Subscribe the session to a topic selector in order to receive updates and | ||
* {@link FetchStream} will emit <code>value</code> events for each topic that is matched for which a fetch request | ||
* can be satisfied. Once complete, the {@link FetchStream will be closed. | ||
* can be satisfied. Once complete, the {@link FetchStream} will be closed. | ||
* | ||
@@ -190,0 +190,0 @@ * @param {String|TopicSelector} selector - The topic selector to fetch |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -32,3 +32,3 @@ /** | ||
*/ | ||
var Metadata = interface('Metadata', [ | ||
var Metadata = _interface('Metadata', [ | ||
'String', | ||
@@ -60,3 +60,3 @@ | ||
*/ | ||
Metadata.Stateless = interface('Stateless', []); | ||
Metadata.Stateless = _interface('Stateless', []); | ||
@@ -74,3 +74,3 @@ /** | ||
*/ | ||
Metadata.String = interface('String', [ | ||
Metadata.String = _interface('String', [ | ||
'value' | ||
@@ -90,3 +90,3 @@ ]); | ||
*/ | ||
Metadata.Integer = interface('Integer', [ | ||
Metadata.Integer = _interface('Integer', [ | ||
'value' | ||
@@ -110,3 +110,3 @@ ]); | ||
*/ | ||
Metadata.Decimal = interface('Decimal', [ | ||
Metadata.Decimal = _interface('Decimal', [ | ||
'value', | ||
@@ -129,3 +129,3 @@ 'scale' | ||
*/ | ||
Metadata.RecordContent = interface('RecordContent', [ | ||
Metadata.RecordContent = _interface('RecordContent', [ | ||
/** | ||
@@ -275,3 +275,3 @@ * Specify the minimum and maximum number of times a | ||
*/ | ||
Metadata.RecordContent.Record = interface('Record', [ | ||
Metadata.RecordContent.Record = _interface('Record', [ | ||
/** | ||
@@ -368,3 +368,3 @@ * The name of this record. Used for adding records via | ||
*/ | ||
Metadata.RecordContent.Field = interface('MField', [ | ||
Metadata.RecordContent.Field = _interface('MField', [ | ||
/** | ||
@@ -371,0 +371,0 @@ * The name of this field. |
@@ -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 @@ }; |
@@ -113,3 +113,4 @@ var topicSelectorParser = require('topics/topic-selector-parser'); | ||
content : response.message, | ||
options : response.options | ||
options : response.options, | ||
path : response.path | ||
}; | ||
@@ -121,2 +122,3 @@ // Only set properties if there are some present. | ||
} | ||
handler.onMessage(message); | ||
@@ -123,0 +125,0 @@ return false; |
@@ -21,2 +21,3 @@ var implements = require('util/interface').implements; | ||
var UniversalUpdater = require('features/topic-control/universal-updater'); | ||
var ValueCache = require('features/topic-control/value-cache'); | ||
@@ -41,4 +42,4 @@ var deriveDetails = require('topics/details/topic-details').deriveDetails; | ||
var valueCache = {}; | ||
var universalUpdater = new UniversalUpdater(valueCache, internal); | ||
var valueCache = new ValueCache(); | ||
var universalUpdater = new UniversalUpdater(internal); | ||
@@ -110,3 +111,3 @@ // Updater state service | ||
valueCache[path] = content; | ||
valueCache.put(path, content); | ||
@@ -124,3 +125,3 @@ emitter.emit('complete', { | ||
valueCache[path] = content; | ||
valueCache.put(path, content); | ||
@@ -127,0 +128,0 @@ emitter.emit('complete', { |
var Services = require('services/services'); | ||
var DataTypes = require('data/datatypes'); | ||
module.exports = function UniversalUpdater(valueCache, internal) { | ||
var DELTA_SERVICE = internal.getServiceLocator().obtain(Services.UPDATE_TOPIC_DELTA); | ||
module.exports = function UniversalUpdater(internal) { | ||
var SET_SERVICE = internal.getServiceLocator().obtain(Services.UPDATE_TOPIC_SET); | ||
@@ -16,25 +15,7 @@ | ||
if (valueCache[topic]) { | ||
var deltaType = datatype.deltaType("binary"); | ||
var delta = deltaType.diff(valueCache[topic], value); | ||
if (delta === deltaType.noChange()) { | ||
callback(null, {}); | ||
return; | ||
} | ||
DELTA_SERVICE.send({ | ||
id : 0, | ||
path : topic, | ||
bytes : dataToBytes(delta) | ||
}, callback); | ||
} else { | ||
SET_SERVICE.send({ | ||
path : topic, | ||
bytes : dataToBytes(value) | ||
}, callback); | ||
} | ||
valueCache[topic] = value; | ||
SET_SERVICE.send({ | ||
path : topic, | ||
bytes : dataToBytes(value) | ||
}, callback); | ||
}; | ||
}; |
var implements = require('util/interface').implements; | ||
var FetchStream = require('../../../events/fetch-stream'); | ||
var TypedFetchStream = require('features/topics/typed-fetch-stream'); | ||
module.exports = implements(FetchStream, function FetchStreamImpl(emitter) { | ||
emitter.assign(this); | ||
this.asType = function(datatype) { | ||
return new TypedFetchStream(emitter, datatype); | ||
}; | ||
}); |
@@ -0,1 +1,4 @@ | ||
var parseSelector = require('topics/topic-selector-parser'); | ||
var canonicalise = require('topics/topic-path-utils').canonicalise; | ||
var Services = require('services/services'); | ||
@@ -13,2 +16,7 @@ var DataTypes = require('data/datatypes'); | ||
function clearCache(cache, path) { | ||
var selector = parseSelector('?' + canonicalise(path) + '//'); | ||
cache.remove(selector); | ||
} | ||
function Updater(cid, dispatch) { | ||
@@ -64,6 +72,7 @@ var self = this; | ||
var value = datatype.from(content); | ||
var prev = valueCache.get(path); | ||
if (valueCache[path]) { | ||
if (prev) { | ||
var deltaType = datatype.deltaType("binary"); | ||
var delta = deltaType.diff(valueCache[path], value); | ||
var delta = deltaType.diff(prev, value); | ||
@@ -89,3 +98,3 @@ if (delta === deltaType.noChange()) { | ||
valueCache[path] = value; | ||
valueCache.put(path, value); | ||
} | ||
@@ -139,2 +148,5 @@ } | ||
updater = new Updater(cid, dispatch); | ||
clearCache(valueCache, topic); | ||
handler.onActive(topic, updater); | ||
@@ -146,2 +158,4 @@ return false; | ||
default : | ||
clearCache(valueCache, topic); | ||
handler.onClose(topic); | ||
@@ -158,2 +172,4 @@ return true; | ||
clearCache(valueCache, topic); | ||
handler.onClose(topic, reason); | ||
@@ -160,0 +176,0 @@ } |
@@ -86,8 +86,4 @@ var split = require('util/string').split; | ||
if (type === null) { | ||
if (isAlphaNumeric(expression[0])) { | ||
expression = P.PATH + expression; | ||
type = T.PATH; | ||
} else { | ||
throw new Error("Invalid expression type: " + expression); | ||
} | ||
expression = P.PATH + expression; | ||
type = T.PATH; | ||
} | ||
@@ -174,3 +170,10 @@ | ||
return T.SELECTOR_SET; | ||
case '$': | ||
case '%': | ||
case '&': | ||
case '<': | ||
// Reserved character | ||
throw new Error("Invalid expression type: " + expression); | ||
default: | ||
// Default is to treat null as a path | ||
return null; | ||
@@ -177,0 +180,0 @@ } |
@@ -79,4 +79,4 @@ var DEFAULT_HOST = 'localhost'; | ||
* <td><code>function</code></td> | ||
* <td><code>function(reconnect, abort) { | ||
* setTimeout(reconnect, 5000); | ||
* <td><code>function(reconnect, abort) {<br/> | ||
* setTimeout(reconnect, 5000);<br/> | ||
* }</code></td> | ||
@@ -90,6 +90,6 @@ * <td>A strategy function that will be called when the client enters a <code>disconnected</code> state, and | ||
* <tr> | ||
* <td><code>{ timeout : <number>, strategy : <function> }</code></td> | ||
* <td><code>{ timeout : 60000, strategy : function(reconnect, abort) { | ||
* setTimeout(reconnect, 5000); | ||
* } }</code></td> | ||
* <td><code>{<br/> timeout : <number>,<br /> strategy : <function><br/>}</code></td> | ||
* <td><code>{<br/> timeout : 60000,<br /> strategy : function(reconnect, abort) {<br/> | ||
* setTimeout(reconnect, 5000);</br> | ||
* }<br />}</code></td> | ||
* <td>An object containing both the timeout and strategy options as specified above, allowing both to be set together. | ||
@@ -114,3 +114,3 @@ * </td> | ||
* <td><code>ws</code>, <code>WS</code>, <code>WEBSOCKET</code></td> | ||
* <td>The websocket transport. A single, long-lived websocket connection will be used to send and receive data.</td> | ||
* <td>The WebSocket transport. A single, long-lived WebSocket connection will be used to send and receive data.</td> | ||
* </tr> | ||
@@ -117,0 +117,0 @@ * <tr> |
@@ -1,2 +0,2 @@ | ||
var interface = require('util/interface').interface; | ||
var _interface = require('util/interface').interface; | ||
@@ -58,3 +58,3 @@ /** | ||
*/ | ||
module.exports = interface('TopicSpecification', [ | ||
module.exports = _interface('TopicSpecification', [ | ||
/** | ||
@@ -61,0 +61,0 @@ * The topic type. |
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
520491
271
14382