chrome-net
Advanced tools
Comparing version 3.1.3 to 3.2.0
39
index.js
@@ -105,3 +105,6 @@ /*global chrome */ | ||
exports.connect = exports.createConnection = function () { | ||
var args = normalizeConnectArgs(arguments) | ||
const argsLen = arguments.length | ||
var args = new Array(argsLen) | ||
for (var i = 0; i < argsLen; i++) args[i] = arguments[i] | ||
args = normalizeConnectArgs(args) | ||
var s = new Socket(args[0]) | ||
@@ -408,2 +411,10 @@ return Socket.prototype.connect.apply(s, args) | ||
Object.defineProperty(Server.prototype, 'listening', { | ||
get: function () { | ||
return !!this._address | ||
}, | ||
configurable: true, | ||
enumerable: true | ||
}) | ||
/** | ||
@@ -545,3 +556,3 @@ * Returns the bound address, the address family name and port of the socket | ||
if (options.server) { | ||
this.server = options.server | ||
this.server = this._server = options.server | ||
this.id = options.id | ||
@@ -570,2 +581,6 @@ sockets[this.id] = this | ||
this._bytesDispatched = 0 | ||
// Reserve properties | ||
this.server = null | ||
this._server = null | ||
} | ||
@@ -607,3 +622,6 @@ | ||
Socket.prototype.connect = function () { | ||
var args = normalizeConnectArgs(arguments) | ||
const argsLen = arguments.length | ||
var args = new Array(argsLen) | ||
for (var i = 0; i < argsLen; i++) args[i] = arguments[i] | ||
args = normalizeConnectArgs(args) | ||
var options = args[0] | ||
@@ -757,3 +775,3 @@ var cb = args[1] | ||
var buffer = chunk.buffer | ||
if (chunk.byteOffset || chunk.byteLength !== buffer.byteLength) { | ||
if (chunk.byteLength !== buffer.byteLength) { | ||
buffer = buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength) | ||
@@ -782,3 +800,3 @@ } | ||
if (this._connecting || !this.id) { | ||
this.once('connect', this._read.bind(this, bufferSize)) | ||
this.once('connect', () => this._read(bufferSize)) | ||
return | ||
@@ -859,6 +877,5 @@ } | ||
if (this.server) { | ||
this.server._connections -= 1 | ||
if (this.server._emitCloseIfDrained) this.server._emitCloseIfDrained() | ||
this.server = null | ||
if (this._server) { | ||
this._server._connections -= 1 | ||
if (this._server._emitCloseIfDrained) this._server._emitCloseIfDrained() | ||
} | ||
@@ -949,3 +966,3 @@ | ||
if (!this.id) { | ||
this.once('connect', this.setNoDelay.bind(this, noDelay, callback)) | ||
this.once('connect', () => this.setNoDelay(noDelay, callback)) | ||
return this | ||
@@ -981,3 +998,3 @@ } | ||
if (!this.id) { | ||
this.once('connect', this.setKeepAlive.bind(this, enable, initialDelay, callback)) | ||
this.once('connect', () => this.setKeepAlive(enable, initialDelay, callback)) | ||
return this | ||
@@ -984,0 +1001,0 @@ } |
{ | ||
"name": "chrome-net", | ||
"description": "Use the Node `net` API in Chrome Apps", | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)", | ||
@@ -6,0 +6,0 @@ "bugs": { |
38094
1019