Comparing version 0.2.2 to 0.6.0
@@ -14,4 +14,13 @@ var sys = require('sys'), | ||
frame = null; | ||
var residual = null; | ||
return function(data) { | ||
// Prepend any residual data from our previous read | ||
if (residual) { | ||
var dat = new Buffer(data.length + residual.length); | ||
residual.copy(dat, 0, 0); | ||
data.copy(dat, residual.length, 0); | ||
residual = null; | ||
} | ||
// var buf = new Buffer(data, 'binary'); | ||
@@ -24,3 +33,6 @@ // console.log(buf); | ||
if (data.length < 4) { | ||
throw Error("Not enough bytes"); | ||
console.log("Expecting > 4 bytes, found only " + data.length); | ||
residual = data; | ||
break; | ||
//throw Error("Expecting > 4 bytes, found only " + data.length); | ||
} | ||
@@ -47,3 +59,3 @@ frameLeft = BinaryParser.toInt(data.slice(0,4)); | ||
}; | ||
} | ||
}; | ||
@@ -95,3 +107,3 @@ var Connection = exports.Connection = function(stream, options) { | ||
})); | ||
} | ||
}; | ||
sys.inherits(Connection, EventEmitter); | ||
@@ -98,0 +110,0 @@ |
@@ -70,3 +70,3 @@ var sys = require('sys'); | ||
ret = input.readString() | ||
this.message = ret.value | ||
this.message = ret | ||
} else { | ||
@@ -80,3 +80,3 @@ ret = input.skip(ret.ftype) | ||
ret = input.readI32() | ||
this.type = ret.value | ||
this.type = ret | ||
} else { | ||
@@ -115,1 +115,9 @@ ret = input.skip(ret.ftype) | ||
} | ||
exports.objectLength = function(obj) { | ||
return Object.keys(obj).length; | ||
} | ||
exports.inherits = function(constructor, superConstructor) { | ||
sys.inherits(constructor, superConstructor); | ||
} |
@@ -1,69 +0,57 @@ | ||
var TMemoryBuffer = exports.TMemoryBuffer = function(buffer, flushCallback) { | ||
if (buffer !== undefined) { | ||
this.recv_buf = buffer; | ||
} else { | ||
this.recv_buf = new Buffer(0); | ||
} | ||
this.recv_buf_sz = this.recv_buf.length; | ||
this.send_buf = []; | ||
this.rpos = 0; | ||
this.flushCallback = flushCallback; | ||
} | ||
var emptyBuf = new Buffer(0); | ||
TMemoryBuffer.prototype.isOpen = function() { | ||
// TODO | ||
return true; | ||
} | ||
var TMemoryBuffer = exports.TMemoryBuffer = function(buffer, callback) { | ||
this.inBuf = buffer || emptyBuf; | ||
this.outBuffers = []; | ||
this.outCount = 0; | ||
this.readPos = 0; | ||
this.onFlush = callback; | ||
}; | ||
TMemoryBuffer.prototype.open = function() { | ||
} | ||
TMemoryBuffer.prototype = { | ||
// TODO: Implement open/close support | ||
isOpen: function() {return true;}, | ||
open: function() {}, | ||
close: function() {}, | ||
TMemoryBuffer.prototype.close = function() { | ||
} | ||
read: function(len) { | ||
var end = this.readPos + len; | ||
TMemoryBuffer.prototype.read = function(len) { | ||
var avail = this.recv_buf_sz - this.rpos; | ||
// console.log("avail: " + avail); | ||
if (this.inBuf.length < end) { | ||
throw new Error('read(' + len + ') failed - not enough data'); | ||
} | ||
if(avail == 0) | ||
return new Buffer(0); | ||
var buf = this.inBuf.slice(this.readPos, end); | ||
this.readPos = end; | ||
return buf; | ||
}, | ||
var give = len | ||
readAll: function() { | ||
return this.inBuf; | ||
}, | ||
if(avail < len) { | ||
console.log("asked for: " + len); | ||
throw new Error("asked for too much"); | ||
give = avail | ||
} | ||
write: function(buf, encoding) { | ||
if (typeof(buf) === "string") { | ||
// Defaulting to ascii encoding here since that's more like the original | ||
// code, but I feel like 'utf8' would be a better choice. | ||
buf = new Buffer(buf, encoding || 'ascii'); | ||
} | ||
this.outBuffers.push(buf); | ||
this.outCount += buf.length; | ||
}, | ||
// console.log(this.rpos + "," + give); | ||
var ret = this.recv_buf.slice(this.rpos,this.rpos + give) | ||
this.rpos += give | ||
// console.log(ret); | ||
flush: function() { | ||
var out = new Buffer(this.outCount), pos = 0; | ||
this.outBuffers.forEach(function(buf) { | ||
buf.copy(out, pos, 0); | ||
pos += buf.length; | ||
}); | ||
//clear buf when complete? | ||
return ret | ||
if (this.onFlush) { | ||
this.onFlush(out); | ||
} | ||
} | ||
TMemoryBuffer.prototype.readAll = function() { | ||
return this.recv_buf; | ||
} | ||
TMemoryBuffer.prototype.write = function(buf) { | ||
// TODO | ||
if (typeof(buf) === "string") { | ||
for (var i = 0; i < buf.length; ++i) { | ||
this.send_buf.push(buf.charCodeAt(i)); | ||
} | ||
} else { | ||
for (var i = 0; i < buf.length; ++i) { | ||
this.send_buf.push(buf[i]); | ||
} | ||
this.outBuffers = []; | ||
this.outCount = 0; | ||
} | ||
} | ||
TMemoryBuffer.prototype.flush = function() { | ||
this.flushCallback(new Buffer(this.send_buf)); | ||
this.send_buf = []; | ||
} | ||
}; |
{ | ||
"name": "thrift", | ||
"description": "node-thrift", | ||
"version": "0.2.2", | ||
"version": "0.6.0", | ||
"author": "Wade Simmons <wade@wades.im>", | ||
@@ -6,0 +6,0 @@ "directories" : { "lib" : "./lib/thrift" }, |
@@ -13,11 +13,11 @@ # node-thrift | ||
## Install | ||
npm install thrift | ||
## Thrift Compiler | ||
A Thrift compiler is being built in a forked version of the upstream thrift | ||
library. You can check it out here: | ||
[https://github.com/wadey/thrift](http://github.com/wadey/thrift) | ||
A Thrift compiler is included in the 0.6.0 release of Thrift. You can | ||
compile nodejs sources by running the following: | ||
Once you build this patched version of Thrift, you can compile nodejs sources | ||
by running the following: | ||
thrift --gen js:node thrift_file | ||
@@ -24,0 +24,0 @@ |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 30 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
1
3162
4
179475
49