PHP 7.4.33
Preview: delay-async-destroy.js Size: 652 B
//usr/share/nodejs/http2-wrapper/source/utils/delay-async-destroy.js
'use strict';

module.exports = stream => {
	if (stream.listenerCount('error') !== 0) {
		return;
	}

	stream.__destroy = stream._destroy;
	stream._destroy = (...args) => {
		const callback = args.pop();

		stream.__destroy(...args, async error => {
			await Promise.resolve();
			callback(error);
		});
	};

	const onError = error => {
		// eslint-disable-next-line promise/prefer-await-to-then
		Promise.resolve().then(() => {
			stream.emit('error', error);
		});
	};

	stream.once('error', onError);

	// eslint-disable-next-line promise/prefer-await-to-then
	Promise.resolve().then(() => {
		stream.off('error', onError);
	});

	return stream;
};

Directory Contents

Dirs: 0 × Files: 10
Name Size Perms Modified Actions
449 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
473 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
652 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
1.45 KB lrw-r--r-- 2021-11-20 15:22:42
Edit Download
186 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
237 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
149 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
2.33 KB lrw-r--r-- 2021-11-20 15:22:42
Edit Download
385 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
400 B lrw-r--r-- 2021-11-20 15:22:42
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).