New Upstream Release - node-timed-out

Ready changes

Summary

Merged new upstream version: 6.0.0 (was: 5.0.0).

Resulting package

Built on 2022-03-07T12:11 (took 1m49s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases node-timed-out

Lintian Result

Diff

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..6313b56
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto eol=lf
diff --git a/.github/funding.yml b/.github/funding.yml
new file mode 100644
index 0000000..aaf6861
--- /dev/null
+++ b/.github/funding.yml
@@ -0,0 +1,2 @@
+github: sindresorhus
+tidelift: npm/timed-out
diff --git a/.github/security.md b/.github/security.md
new file mode 100644
index 0000000..5358dc5
--- /dev/null
+++ b/.github/security.md
@@ -0,0 +1,3 @@
+# Security Policy
+
+To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..3b8aa86
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,22 @@
+name: CI
+on:
+  - push
+  - pull_request
+jobs:
+  test:
+    name: Node.js ${{ matrix.node-version }}
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        node-version:
+          - 16
+          - 14
+          - 12
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v2
+        with:
+          node-version: ${{ matrix.node-version }}
+      - run: npm install
+      - run: npm test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..239ecff
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+yarn.lock
diff --git a/debian/changelog b/debian/changelog
index 96324c2..3070dad 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+node-timed-out (6.0.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 07 Mar 2022 12:09:37 -0000
+
 node-timed-out (5.0.0-2) unstable; urgency=medium
 
   * Team upload
diff --git a/debian/patches/disable-network-tests.patch b/debian/patches/disable-network-tests.patch
index 0941cbd..bf91610 100644
--- a/debian/patches/disable-network-tests.patch
+++ b/debian/patches/disable-network-tests.patch
@@ -5,19 +5,21 @@ Forwarded: not-needed
 Reviewed-By: Xavier Guimard <yadd@debian.org>
 Last-Update: 2020-10-29
 
---- a/test.js
-+++ b/test.js
-@@ -7,6 +7,7 @@
- 
- const port = Math.floor((Math.random() * (60000 - 30000)) + 30000);
+Index: node-timed-out/test.js
+===================================================================
+--- node-timed-out.orig/test.js
++++ node-timed-out/test.js
+@@ -10,6 +10,7 @@ const port = Math.floor((Math.random() *
+ const socketTimeout = socket => ('timeout' in socket) ? socket.timeout : socket._idleTimeout;
+ const socketClosedValue = socket => ('timeout' in socket) ? 0 : -1;
  
 +/*
  it('should do HTTP request with a lot of time', done => {
  	const request = http.get('http://google.com', response => {
  		assert.ok(response.statusCode > 300 && response.statusCode < 399);
-@@ -32,6 +33,7 @@
+@@ -35,6 +36,7 @@ it('should emit ETIMEDOUT when connectio
  
- 	timeout(request, 200);
+ 	timedOut(request, 200);
  });
 +*/
  
diff --git a/index.js b/index.js
index e9d7f19..2ed54d1 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,4 @@
-'use strict';
-
-module.exports = (request, time) => {
+export default function timedOut(request, time) {
 	if (request.timeoutTimer) {
 		return request;
 	}
@@ -52,4 +50,4 @@ module.exports = (request, time) => {
 	};
 
 	return request.on('error', clear);
-};
+}
diff --git a/license b/license
index 84d6996..224d891 100644
--- a/license
+++ b/license
@@ -1,7 +1,7 @@
 MIT License
 
 Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com>
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
diff --git a/package.json b/package.json
index 80553d4..b63a307 100644
--- a/package.json
+++ b/package.json
@@ -1,11 +1,14 @@
 {
 	"name": "timed-out",
-	"version": "5.0.0",
+	"version": "6.0.0",
 	"description": "Timeout HTTP/HTTPS requests",
 	"license": "MIT",
 	"repository": "sindresorhus/timed-out",
+	"funding": "https://github.com/sponsors/sindresorhus",
+	"type": "module",
+	"exports": "./index.js",
 	"engines": {
-		"node": ">=8"
+		"node": ">=12"
 	},
 	"scripts": {
 		"test": "xo && mocha"
@@ -24,7 +27,7 @@
 		"simple"
 	],
 	"devDependencies": {
-		"mocha": "^6.2.0",
-		"xo": "^0.24.0"
+		"mocha": "^8.3.2",
+		"xo": "^0.39.1"
 	}
 }
diff --git a/readme.md b/readme.md
index cbeed3b..7423572 100644
--- a/readme.md
+++ b/readme.md
@@ -1,22 +1,19 @@
-# timed-out [![Build Status](https://travis-ci.org/floatdrop/timed-out.svg?branch=master)](https://travis-ci.org/floatdrop/timed-out)
+# timed-out
 
 > Timeout HTTP/HTTPS requests
 
 Emits Error object with `code` property equal `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged.
 
-
 ## Usage
 
 ```js
-const timedOut = require('timed-out');
-const http = require('http');
-const timedOut = require('timed-out');
+import http from 'node:http';
+import timedOut from 'timed-out';
 
 const request = http.get('http://www.google.ru');
 timedOut(request, 2000); // Sets a 2 seconds limit
 ```
 
-
 ## API
 
 ### timedout(request, time)
@@ -39,3 +36,9 @@ Or you can pass an object with the following fields:
 
 - `connect` - Time to wait for a connection.
 - `socket`  - Time to wait for activity on the socket.
+
+## timed-out for enterprise
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of timed-out and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-timed-out?utm_source=npm-timed-out&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
diff --git a/test.js b/test.js
index 3a2e4e1..6218c64 100644
--- a/test.js
+++ b/test.js
@@ -1,12 +1,15 @@
 /* global describe, before, after, it */
-'use strict';
-const {strict: assert} = require('assert');
-const http = require('http');
-const net = require('net');
-const timeout = require('.');
+import {strict as assert} from 'node:assert';
+import http from 'node:http';
+import net from 'node:net';
+import timedOut from './index.js';
 
 const port = Math.floor((Math.random() * (60000 - 30000)) + 30000);
 
+// Helper functions to return socket timeout property and value
+const socketTimeout = socket => ('timeout' in socket) ? socket.timeout : socket._idleTimeout;
+const socketClosedValue = socket => ('timeout' in socket) ? 0 : -1;
+
 it('should do HTTP request with a lot of time', done => {
 	const request = http.get('http://google.com', response => {
 		assert.ok(response.statusCode > 300 && response.statusCode < 399);
@@ -15,10 +18,10 @@ it('should do HTTP request with a lot of time', done => {
 
 	request.on('error', done);
 
-	timeout(request, 1000);
+	timedOut(request, 1000);
 });
 
-it.skip('should emit ETIMEDOUT when connection timeout expires', done => {
+it('should emit ETIMEDOUT when connection timeout expires', done => {
 	// To prevent the connection from being established use a non-routable IP
 	// address. See https://tools.ietf.org/html/rfc5737#section-3
 	const request = http.get('http://192.0.2.1');
@@ -30,7 +33,7 @@ it.skip('should emit ETIMEDOUT when connection timeout expires', done => {
 		}
 	});
 
-	timeout(request, 200);
+	timedOut(request, 200);
 });
 
 describe('when connection is established', () => {
@@ -57,7 +60,7 @@ describe('when connection is established', () => {
 			}
 		});
 
-		timeout(request, 200);
+		timedOut(request, 200);
 	});
 
 	it('should emit ESOCKETTIMEDOUT (only first chunk of body)', done => {
@@ -91,7 +94,7 @@ describe('when connection is established', () => {
 			}
 		});
 
-		timeout(request, {socket: 200, connect: 50});
+		timedOut(request, {socket: 200, connect: 50});
 	});
 
 	it('should be able to only apply connect timeout', done => {
@@ -107,7 +110,7 @@ describe('when connection is established', () => {
 		request.on('error', done);
 		request.on('finish', done);
 
-		timeout(request, {connect: 50});
+		timedOut(request, {connect: 50});
 	});
 
 	it('should be able to only apply socket timeout', done => {
@@ -127,7 +130,7 @@ describe('when connection is established', () => {
 			}
 		});
 
-		timeout(request, {socket: 50});
+		timedOut(request, {socket: 50});
 	});
 
 	// Different requests may reuse one socket if keep-alive is enabled
@@ -157,14 +160,14 @@ describe('when connection is established', () => {
 				server.removeAllListeners('request');
 				done();
 			});
-			timeout(request2, 100);
+			timedOut(request2, 100);
 
 			request2.on('socket', socket_ => {
 				assert.equal(socket_, socket);
 				assert.equal(socket_.listeners('connect').length, 0);
 			});
 		});
-		timeout(request1, 100);
+		timedOut(request1, 100);
 
 		request1.on('socket', socket_ => {
 			socket = socket_;
@@ -187,11 +190,11 @@ describe('when connection is established', () => {
 				}
 			});
 
-			timeout(request, 200);
+			timedOut(request, 200);
 		});
 	});
 
-	it.skip('should clear socket timeout for keep-alive sockets', done => {
+	it('should clear socket timeout for keep-alive sockets', done => {
 		server.once('request', (request, response) => {
 			response.writeHead(200);
 			response.end('data');
@@ -210,21 +213,21 @@ describe('when connection is established', () => {
 		};
 
 		const request = http.get(options, response => {
-			assert.equal(socket.timeout, 100);
+			assert.equal(socketTimeout(socket), 100);
 			response.resume();
 			response.on('end', () => {
 				assert.equal(socket.destroyed, false);
-				assert.equal(socket.timeout, -1);
+				assert.equal(socketTimeout(socket), socketClosedValue(socket));
 				agent.destroy();
 				done();
 			});
 		});
 
-		timeout(request, 100);
+		timedOut(request, 100);
 
 		request.on('socket', socket_ => {
 			socket_.once('connect', () => {
-				assert.equal(socket_.timeout, 100);
+				assert.equal(socketTimeout(socket), 100);
 			});
 			socket = socket_;
 		});

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details