Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lazy-socket

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-socket - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

8

lib/LazySocket.js

@@ -10,2 +10,3 @@ var net = require('net');

this._socket = null;
this._callbacks = [];

@@ -37,2 +38,3 @@ }

this._lazyConnect();
try {

@@ -64,3 +66,7 @@ this._socket.write.apply(this._socket, args);

LazySocket.prototype.end = function() {
this._socket.end();
if (this._socket) this._socket.end();
};
LazySocket.prototype.destroy = function() {
if (this._socket) this._socket.destroy();
};

4

package.json

@@ -5,3 +5,3 @@ {

"description": "A stateless socket that always lets you write().",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/felixge/node-lazy-socket",

@@ -20,3 +20,3 @@ "repository": {

"utest": "0.0.3",
"sinon": "~1.2.0",
"sinon": "1.2.0",
"urun": "0.0.4"

@@ -23,0 +23,0 @@ },

@@ -5,2 +5,3 @@ var common = require('../common');

var LazySocket = common.LazySocket;
var sinon = require('sinon');
var net = require('net');

@@ -20,1 +21,42 @@

});
var socket;
var fakeSocket;
test('LazySocket', {
before: function() {
socket = new LazySocket();
fakeSocket = sinon.stub(Object.create(net.Socket.prototype));
sinon.stub(net, 'createConnection').returns(fakeSocket);
fakeSocket.once.returns(fakeSocket);
// To establish a connection
socket.write();
},
after: function() {
net.createConnection.restore();
},
'#end when disconnected (does not blow up)': function() {
socket = new LazySocket();
socket.end();
},
'#end when connected': function() {
socket.end();
assert.ok(fakeSocket.end.calledOnce);
},
'#destroy when disconnected (does not blow up)': function() {
var socket = new LazySocket();
socket.destroy();
},
'#destroy when connected': function() {
socket.destroy();
assert.ok(fakeSocket.destroy.calledOnce);
},
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc