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

defer-to-connect

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defer-to-connect - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

14

index.js
'use strict';
// Inspired by https://github.com/nodejs/node/blob/949e8851484c016c07f6cc9e5889f0f2e56baf2a/lib/_http_client.js#L706
module.exports = (socket, method, ...args) => {
let call;
if (typeof method === 'function') {
call = method;
} else {
call = () => socket[method](...args);
}
module.exports = (socket, callback) => {
if (socket.writable && !socket.connecting) {
call();
callback();
} else {
socket.once('connect', call);
socket.once('connect', callback);
}
};
{
"name": "defer-to-connect",
"version": "1.0.1",
"version": "1.0.2",
"description": "The safe way to handle the `connect` socket event",

@@ -11,6 +11,15 @@ "main": "index.js",

"socket",
"connect"
"connect",
"event"
],
"author": "Szymon Marczak",
"license": "MIT"
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/szmarczak/defer-to-connect.git"
},
"bugs": {
"url": "https://github.com/szmarczak/defer-to-connect/issues"
},
"homepage": "https://github.com/szmarczak/defer-to-connect#readme"
}

@@ -20,6 +20,2 @@ # defer-to-connect

### deferToConnect(socket, method, ...args)
Calls `socket[method](...args)` when connected.
### deferToConnect(socket, fn)

@@ -26,0 +22,0 @@

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