Utils

Useful library with JavaScript utilities.

Mint 2020.06.25.. Lásd a legutóbbi verzió

Ezt a szkriptet nem ajánlott közvetlenül telepíteni. Ez egy könyvtár más szkriptek számára, amik tartalmazzák a // @require https://update.greasyfork.org/scripts/405813/820304/Utils.js hivatkozást.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Utils
// @namespace https://rafaelgssa.gitlab.io/monkey-scripts
// @version 2.0.0
// @author rafaelgssa
// @description Useful library with JavaScript utilities.
// @match *://*/*
// ==/UserScript==

// eslint-disable-next-line
const Utils = (() => {
	/**
	 * Checks if a value is set.
	 * @template T
	 * @param {T} value The value to check.
	 * @returns {value is NonNullable<T>}
	 */
	const isSet = (value) => {
		return typeof value !== 'undefined' && value !== null;
	};

	/**
	 * Sleeps for a number of seconds.
	 * @param {number} seconds
	 * @returns {Promise<void>}
	 */
	const sleep = (seconds) => {
		return new Promise((resolve) => window.setTimeout(resolve, seconds * 1000));
	};

	return {
		isSet,
		sleep,
	};
})();