defer-to-connect
Advanced tools
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
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2327
0
1
0
8
27
1