remove useless new Buffer(guidParse.parse(...)) since it's now returning a buffer
This commit is contained in:
parent
60d2a1e5ee
commit
20de4c3715
|
@ -26,7 +26,7 @@ util.inherits(AppendToStreamOperation, OperationBase);
|
||||||
|
|
||||||
AppendToStreamOperation.prototype._createRequestDto = function() {
|
AppendToStreamOperation.prototype._createRequestDto = function() {
|
||||||
var dtos = this._events.map(function(ev) {
|
var dtos = this._events.map(function(ev) {
|
||||||
var eventId = new Buffer(guidParse.parse(ev.eventId));
|
var eventId = guidParse.parse(ev.eventId);
|
||||||
return {
|
return {
|
||||||
eventId: eventId, eventType: ev.type,
|
eventId: eventId, eventType: ev.type,
|
||||||
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
||||||
|
|
|
@ -92,7 +92,7 @@ ConnectToPersistentSubscriptionOperation.prototype.notifyEventsProcessed = funct
|
||||||
var dto = new ClientMessage.PersistentSubscriptionAckEvents({
|
var dto = new ClientMessage.PersistentSubscriptionAckEvents({
|
||||||
subscriptionId: this._subscriptionId,
|
subscriptionId: this._subscriptionId,
|
||||||
processedEventIds: processedEvents.map(function (x) {
|
processedEventIds: processedEvents.map(function (x) {
|
||||||
return new Buffer(guidParse.parse(x));
|
return guidParse.parse(x);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ ConnectToPersistentSubscriptionOperation.prototype.notifyEventsFailed = function
|
||||||
ensure.notNull(reason, "reason");
|
ensure.notNull(reason, "reason");
|
||||||
var dto = new ClientMessage.PersistentSubscriptionNakEvents({
|
var dto = new ClientMessage.PersistentSubscriptionNakEvents({
|
||||||
subscriptionId: this._subscriptionId,
|
subscriptionId: this._subscriptionId,
|
||||||
processedEventIds: processedEvents.map(function(x) { return new Buffer(guidParse.parse(x)); }),
|
processedEventIds: processedEvents.map(function(x) { return guidParse.parse(x); }),
|
||||||
message: reason,
|
message: reason,
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,7 @@ util.inherits(TransactionalWriteOperation, OperationBase);
|
||||||
|
|
||||||
TransactionalWriteOperation.prototype._createRequestDto = function() {
|
TransactionalWriteOperation.prototype._createRequestDto = function() {
|
||||||
var dtos = this._events.map(function(ev) {
|
var dtos = this._events.map(function(ev) {
|
||||||
var eventId = new Buffer(guidParse.parse(ev.eventId));
|
var eventId = guidParse.parse(ev.eventId);
|
||||||
return {
|
return {
|
||||||
eventId: eventId, eventType: ev.type,
|
eventId: eventId, eventType: ev.type,
|
||||||
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
dataContentType: ev.isJson ? 1 : 0, metadataContentType: 0,
|
||||||
|
|
|
@ -16,32 +16,31 @@ function parse(s, buf, offset) {
|
||||||
if (buf) buf.fill(0, i, i + 16);
|
if (buf) buf.fill(0, i, i + 16);
|
||||||
buf = buf || new Buffer(16);
|
buf = buf || new Buffer(16);
|
||||||
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
|
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
|
||||||
if (ii < 4) {
|
if (ii < 16) { // Don't overflow!
|
||||||
buf[i + (3 - ii++)] = _hexToByte[oct]
|
|
||||||
} else if (ii < 6) {
|
|
||||||
buf[i + 4 + (5 - ii++)] = _hexToByte[oct]
|
|
||||||
} else if (ii < 8) {
|
|
||||||
buf[i + 6 + (7 - ii++)] = _hexToByte[oct]
|
|
||||||
} else if (ii < 16) { // Don't overflow!
|
|
||||||
buf[i + ii++] = _hexToByte[oct];
|
buf[i + ii++] = _hexToByte[oct];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var buf2 = new Buffer(buf.slice(i, i + 16));
|
||||||
|
buf[i + 0] = buf2[3];
|
||||||
|
buf[i + 1] = buf2[2];
|
||||||
|
buf[i + 2] = buf2[1];
|
||||||
|
buf[i + 3] = buf2[0];
|
||||||
|
buf[i + 4] = buf2[5];
|
||||||
|
buf[i + 5] = buf2[4];
|
||||||
|
buf[i + 6] = buf2[7];
|
||||||
|
buf[i + 7] = buf2[6];
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
|
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
|
||||||
function unparse(buf, offset) {
|
function unparse(buf, offset) {
|
||||||
var i = offset || 0;
|
var i = offset || 0;
|
||||||
const bth = _byteToHex;
|
return '03020100-0504-0706-0809-101112131415'.replace(/\d{2}/g, function (num) {
|
||||||
return bth[buf[i+3]] + bth[buf[i+2]] +
|
var j = parseInt(num, 10);
|
||||||
bth[buf[i+1]] + bth[buf[i+0]] + '-' +
|
return _byteToHex[buf[i+j]];
|
||||||
bth[buf[i+5]] + bth[buf[i+4]] + '-' +
|
})
|
||||||
bth[buf[i+7]] + bth[buf[i+6]] + '-' +
|
|
||||||
bth[buf[i+8]] + bth[buf[i+9]] + '-' +
|
|
||||||
bth[buf[i+10]] + bth[buf[i+11]] +
|
|
||||||
bth[buf[i+12]] + bth[buf[i+13]] +
|
|
||||||
bth[buf[i+14]] + bth[buf[i+15]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.parse = parse;
|
exports.parse = parse;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user