Beta 7 with some repo names changed.
This commit is contained in:
1 parent
0f7b40cca7
commit
963c19493a
3408 files changed
+462217
-15516
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tls_1 = require("tls");
|
||||
const deferToConnect = (socket, fn) => {
|
||||
let listeners;
|
||||
if (typeof fn === 'function') {
|
||||
const connect = fn;
|
||||
listeners = { connect };
|
||||
}
|
||||
else {
|
||||
listeners = fn;
|
||||
}
|
||||
const hasConnectListener = typeof listeners.connect === 'function';
|
||||
const hasSecureConnectListener = typeof listeners.secureConnect === 'function';
|
||||
const hasCloseListener = typeof listeners.close === 'function';
|
||||
const onConnect = () => {
|
||||
if (hasConnectListener) {
|
||||
listeners.connect();
|
||||
}
|
||||
if (socket instanceof tls_1.TLSSocket && hasSecureConnectListener) {
|
||||
if (socket.authorized) {
|
||||
listeners.secureConnect();
|
||||
}
|
||||
else if (!socket.authorizationError) {
|
||||
socket.once('secureConnect', listeners.secureConnect);
|
||||
}
|
||||
}
|
||||
if (hasCloseListener) {
|
||||
socket.once('close', listeners.close);
|
||||
}
|
||||
};
|
||||
if (socket.writable && !socket.connecting) {
|
||||
onConnect();
|
||||
}
|
||||
else if (socket.connecting) {
|
||||
socket.once('connect', onConnect);
|
||||
}
|
||||
else if (socket.destroyed && hasCloseListener) {
|
||||
listeners.close(socket._hadError);
|
||||
}
|
||||
};
|
||||
exports.default = deferToConnect;
|
||||
// For CommonJS default export support
|
||||
module.exports = deferToConnect;
|
||||
module.exports.default = deferToConnect;
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"_from": "defer-to-connect@^1.0.1",
|
||||
"_id": "defer-to-connect@1.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==",
|
||||
"_location": "/defer-to-connect",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "defer-to-connect@^1.0.1",
|
||||
"name": "defer-to-connect",
|
||||
"escapedName": "defer-to-connect",
|
||||
"rawSpec": "^1.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@szmarczak/http-timer"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz",
|
||||
"_shasum": "331ae050c08dcf789f8c83a7b81f0ed94f4ac591",
|
||||
"_spec": "defer-to-connect@^1.0.1",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\@szmarczak\\http-timer",
|
||||
"author": {
|
||||
"name": "Szymon Marczak"
|
||||
},
|
||||
"ava": {
|
||||
"babel": false,
|
||||
"compileEnhancements": false,
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"files": [
|
||||
"!dist/tests/test.d.ts"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/szmarczak/defer-to-connect/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "The safe way to handle the `connect` socket event",
|
||||
"devDependencies": {
|
||||
"@sindresorhus/tsconfig": "^0.5.0",
|
||||
"@types/node": "^12.12.4",
|
||||
"@typescript-eslint/eslint-plugin": "^1.11.0",
|
||||
"@typescript-eslint/parser": "^1.11.0",
|
||||
"ava": "^2.1.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"create-cert": "^1.0.6",
|
||||
"del-cli": "^3.0.0",
|
||||
"eslint-config-xo-typescript": "^0.15.0",
|
||||
"nyc": "^14.0.0",
|
||||
"p-event": "^4.1.0",
|
||||
"ts-node": "^8.1.0",
|
||||
"typescript": "^3.6.4",
|
||||
"xo": "^0.25.3"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/szmarczak/defer-to-connect#readme",
|
||||
"keywords": [
|
||||
"socket",
|
||||
"connect",
|
||||
"event"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist",
|
||||
"name": "defer-to-connect",
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".ts"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/szmarczak/defer-to-connect.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "del-cli dist && tsc",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "xo && nyc ava"
|
||||
},
|
||||
"types": "dist",
|
||||
"version": "1.1.3",
|
||||
"xo": {
|
||||
"extends": "xo-typescript",
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"rules": {
|
||||
"ava/no-ignored-test-files": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user