#!/usr/bin/env node
//#region src/util/time.ts
function getCurrentTimestamp() {
	return Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
/**
* Sleep that can be interrupted by an abort signal.
* Throws 'cancelled by user' if signal is already aborted or aborts during sleep.
*/
async function sleepWithAbort(ms, signal) {
	if (signal.aborted) throw new Error("cancelled by user");
	return new Promise((resolve, reject) => {
		const timeout = setTimeout(() => {
			signal.removeEventListener("abort", onAbort);
			resolve();
		}, ms);
		const onAbort = () => {
			clearTimeout(timeout);
			reject(/* @__PURE__ */ new Error("cancelled by user"));
		};
		signal.addEventListener("abort", onAbort, { once: true });
	});
}
//#endregion
export { sleep as n, sleepWithAbort as r, getCurrentTimestamp as t };

//# sourceMappingURL=time-CrpgfF3R.js.map