New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonsocket

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

jsonsocket - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

27

lib/JsonSocket.js

@@ -9,23 +9,18 @@ var net = require('net');

function isString(s) {
return (typeof s === 'string' || s instanceof String);
}
function JsonSocket(ip, port) {
function JsonSocket() {
var socket = this;
var connection = null;
var json = "";
if (isString(ip)) {
log('connecting... %s:%s', ip, port);
connection = net.connect({ip: ip, port: port}, function () {
log('connect');
socket.emit('connect');
});
} else if (ip instanceof net.Socket) {
if (arguments[0] instanceof net.Socket) {
log('connect');
connection = ip;
connection =arguments[0];
} else {
throw new Error('Invalid input. Arguments must be ip, port or net.Socket');
connection = net.connect.apply(net, arguments);
}
connection.on('connect', function () {
log('connect');
socket.emit('connect');
});

@@ -61,2 +56,6 @@ connection.on('data', function (data) {

};
socket.connect = function () {
connection.connect.apply(connection, arguments);
};
}

@@ -63,0 +62,0 @@

{
"name": "jsonsocket",
"version": "1.0.1",
"version": "1.0.2",
"description": "JSON socket",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,8 +18,10 @@ # jsonsocket

### `JsonSocket(ip, port)`
### `JsonSocket(options)`
### `JsonSocket(port, [host])`
### `JsonSocket(path)`
Create new json socket from ip and port.
Create new json socket. Same as [`net.connect`](http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener).
```js
var socket = new JsonSocket('127.0.0.1', 7000);
var socket = new JsonSocket(7000, '127.0.0.1');
```

@@ -49,2 +51,7 @@

### `connect(port, [host])`
### `connect(path)`
Same as [`net.Socket.connect`](http://nodejs.org/api/net.html#net_socket_connect_port_host_connectlistener)
### `on(eventType, listener)`

@@ -56,15 +63,2 @@

### error
Emitted when net.Socket emit error.
> Error events are treated as a special case in node. If there is no listener for it,
> then the default action is to print a stack trace and exit the program.
[see more](http://nodejs.org/api/events.html#events_class_events_eventemitter).
### newListener, removeListener
Inherited from [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
### connect

@@ -84,2 +78,15 @@ Emitted when socket connected (only when you pass ip, port).

### error
Emitted when net.Socket emit error.
> Error events are treated as a special case in node. If there is no listener for it,
> then the default action is to print a stack trace and exit the program.
[see more](http://nodejs.org/api/events.html#events_class_events_eventemitter).
### newListener, removeListener
Inherited from [EventEmitter](http://nodejs.org/api/events.html#events_class_events_eventemitter).
## Logging

@@ -86,0 +93,0 @@

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