net‑keepalive: Provides its own types (#45704)

This commit is contained in:
ExE Boss 2020-06-25 19:12:57 +02:00 committed by GitHub
parent 2ce8388594
commit d1564b4f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 66 deletions

View File

@ -2994,6 +2994,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/negative-zero",
"asOfVersion": "3.0.0"
},
{
"libraryName": "net-keepalive",
"typingsPackageName": "net-keepalive",
"sourceRepoURL": "https://github.com/hertzg/node-net-keepalive",
"asOfVersion": "1.0.0"
},
{
"libraryName": "new-github-issue-url",
"typingsPackageName": "new-github-issue-url",

View File

@ -1,10 +0,0 @@
// Type definitions for net-keepalive 0.4
// Project: https://github.com/hertzg/node-net-keepalive
// Definitions by: George Kotchlamazashvili <https://github.com/hertzg>
// Definitions: https://github.com/hertzg/node-net-keepalive
/// <reference types="node" />
export type NodeJSSocketWithFileDescriptor = NodeJS.Socket | { _handle: { _fd: number } }
export function setKeepAliveProbes(socket: NodeJSSocketWithFileDescriptor, cnt: number): number
export function setKeepAliveInterval(socket: NodeJSSocketWithFileDescriptor, intvl: number): number

View File

@ -1,21 +0,0 @@
import NetKeepAlive = require('net-keepalive')
import * as Net from 'net'
const server = Net.createServer((socket) => {
socket.setKeepAlive(true, 1000)
NetKeepAlive.setKeepAliveInterval(socket, 1000)
NetKeepAlive.setKeepAliveProbes(socket, 1)
socket.on('end', () => server.close())
})
server.listen(1337, '127.0.0.1', () => {
const {port, address} = server.address() as Net.AddressInfo
const clientSocket = Net.createConnection({
port, host: address
}, () => {
clientSocket.setKeepAlive(true, 1000)
NetKeepAlive.setKeepAliveInterval(clientSocket, 1000)
NetKeepAlive.setKeepAliveProbes(clientSocket, 1)
clientSocket.end()
})
})

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true
},
"files": [
"index.d.ts",
"net-keepalive-tests.ts"
]
}

View File

@ -1,12 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"eofline": false,
"indent": [
true,
"spaces",
4
],
"semicolon": false
}
}