@emadzedan80/pro-utilities
v1.1.2
Published
A Full Robust Utility Module Containing 92 Math, Form, Array, Object, Date, Time, Devices Recognition, Browsers Recognition & Helper Utilities Functions, All Functions Are Designed To Fail Silently (Returning null/false) & Log Warnings Instead Of Throwing
Maintainers
Readme
Emad Zedan Pro Utilities
Description
A Full Robust Utility Module Containing 92 Math, Form, Array, Object, Date, Time, Devices Recognition, Browsers Recognition & Helper Utilities Functions, All Functions Are Designed To Fail Silently (Returning null/false) & Log Warnings Instead Of Throwing Errors.
✨ Features
- 🚀 Easy To Use.
- ⚡ Lightweight & Fast.
- 🔧 Fully Customizable Error Free.
- 📦 Ready For Production.
📦 Installation
npm install @emadzedan80/pro-utilities
🧩 Usage
// This file demonstrates the usage of some the utilities functions exported from index.js.
import {
// Math Utilities
sum, average, min, max, randomFromTo,
// Forms Utilities
generateUniqueNumber, generateUniqueID, isValidName, isURL, isDomain, isIP, isNumeric, isValidPassword, isCamelCase, isSnakeCase, escHTML, escURL, capitalize,
// Array Utilities
cleanArray, bubbleSortASC, bubbleSortDESC, mergeArrays, arrayHasValue, arrayRemoveDuplicates, generateArray, cloneDeepArray,
// Object Utilities
safeJSONParse, mergeObjects, cloneDeepObject, objectHasKey, objectHasValue,
// Date & Time Utilities
isStringAValidDate, isSameDayName, shortDayName, fullDayName, shortMonthName, fullMonthName, SeasonName, formatNumericDate, formatShortNamedDate, formatFullNamedDate, formatTime24, formatTime12, addSeconds, subtractSeconds, addMinutes, subtractMinutes, addHours, subtractHours, addDays, subtractDays, addMonths, subtractMonths, addYears, subtractYears, isSatOrSun, isFriOrSat, isFriOrSun, isChristmas, isThanksGiving, isNewYear, isWesternEaster, isEasternEaster,
// Devices Utilities
isMobile, isAndroidMobile, isHuaweiMobile, isIPhone, isMobileLandscape, isMobilePortrait, isTablet, isAndroidTablet, isHuaweiTablet, isIPad, isTabletLandscape, isTabletPortrait, isDesktop, isIOS, isMacOS, isWindows, isWindows7, isWindows10, isWindows11, isLinux,
// Browser Utilities
isWebkit, isChrome, isEdge, isFirefox, isOprea, isBrave, isInternetExplorer,
// Helper Utilities
fahrenheitToCelsius, celsiusToFahrenheit, delay
} from "https://cdn.jsdelivr.net/npm/@emadzedan80/pro-utilities/+esm";
const p0 = document.createElement('p');
p0.textContent = '=== 🔢 Math Utilities ===';
document.body.appendChild(p0);
console.log('=== 🔢 Math Utilities ===');
// sum
const p1 = document.createElement('p');
p1.textContent = 'sum(10, 20, [5, 5], "100"): ' + sum(10, 20, [5, 5], "100");
document.body.appendChild(p1);
console.log('sum(10, 20, [5, 5], "100"): ' + sum(10, 20, [5, 5], "100"));
// Output: 40 (Ignores "100", flattens array [5,5])
// average
const p2 = document.createElement('p');
p2.textContent = 'average(10, 20, 30): ' + average(10, 20, 30);
document.body.appendChild(p2);
console.log('average(10, 20, 30): ' + average(10, 20, 30));
// Output: 20
// min
const p3 = document.createElement('p');
p3.textContent = 'min(5, 1, 10, -5): ' + min(5, 1, 10, -5);
document.body.appendChild(p3);
console.log('min(5, 1, 10, -5): ' + min(5, 1, 10, -5));
// Output: -5
// max
const p4 = document.createElement('p');
p4.textContent = 'max(5, 1, 10, -5): ' + max(5, 1, 10, -5);
document.body.appendChild(p4);
console.log('max(5, 1, 10, -5): ' + max(5, 1, 10, -5));
// Output: 10
// randomFromTo
const p5 = document.createElement('p');
p5.textContent = 'randomFromTo(1, 10): ' + randomFromTo(1, 10);
document.body.appendChild(p5);
console.log('randomFromTo(1, 10): ' + randomFromTo(1, 10));
// Output: Random number between 1 and 10 (e.g., 7)
const p00 = document.createElement('p');
p00.textContent = '=== 📝 Form Utilities ===';
document.body.appendChild(p00);
console.log('=== 📝 Form Utilities ===');
// generateUniqueNumber
const p6 = document.createElement('p');
p6.textContent = 'generateUniqueNumber(): ' + generateUniqueNumber();
document.body.appendChild(p6);
console.log('generateUniqueNumber(): ' + generateUniqueNumber());
// Output: Large numeric timestamp (e.g., 1700000000000123)
// generateUniqueID
const p7 = document.createElement('p');
p7.textContent = 'generateUniqueID(): ' + generateUniqueID();
document.body.appendChild(p7);
console.log('generateUniqueID(): ' + generateUniqueID());
// Output: String ID (e.g., "id-lp3x2s-abc123xyz")
// isValidName (Only letters and spaces)
const p8 = document.createElement('p');
p8.textContent = 'isValidName("John Doe"): ' + isValidName(" John Doe ");
document.body.appendChild(p8);
console.log('isValidName("John Doe"): ' + isValidName(" John Doe ")); // Output: true (Trims input)
const p9 = document.createElement('p');
p9.textContent = 'isValidName("John-Doe"): ' + isValidName("John-Doe");
document.body.appendChild(p9);
console.log('isValidName("John-Doe"): ' + isValidName("John-Doe")); // Output: false (Hyphens not allowed)
// isURL
const p10 = document.createElement('p');
p10.textContent = 'isURL("https: //google.com"): ', isURL("https: //google.com");
document.body.appendChild(p10);
console.log('isURL("https: //google.com"): ', isURL("https: //google.com")); // Output: true
const p11 = document.createElement('p');
p11.textContent = 'isURL("google.com"): ' + isURL("google.com");
document.body.appendChild(p11);
console.log('isURL("google.com"): ' + isURL("google.com")); // Output: false (Needs protocol)
// isDomain
const p12 = document.createElement('p');
p12.textContent = 'isDomain("example.com"): ' + isDomain("example.com");
document.body.appendChild(p12);
console.log('isDomain("example.com"): ' + isDomain("example.com")); // Output: true
const p13 = document.createElement('p');
p13.textContent = 'isDomain("sub.domain-name.net"): ' + isDomain("sub.domain-name.net");
document.body.appendChild(p13);
console.log('isDomain("sub.domain-name.net"): ' + isDomain("sub.domain-name.net")); // Output: true
const p14 = document.createElement('p');
p14.textContent = 'isDomain("invalid domain!"): ' + isDomain("invalid domain!");
document.body.appendChild(p14);
console.log('isDomain("invalid domain!"): ' + isDomain("invalid domain!")); // Output: false
// isIP
const p15 = document.createElement('p');
p15.textContent = 'isDomain("invalid domain!"): ' + isDomain("invalid domain!");
document.body.appendChild(p15);
console.log('isIP("192.168.1.1"): ' + isIP("192.168.1.1")); // Output: true
const p16 = document.createElement('p');
p16.textContent = 'isDomain("invalid domain!"): ' + isDomain("invalid domain!");
document.body.appendChild(p16);
console.log('isIP("256.0.0.1"): ' + isIP("256.0.0.1") + "(Octet > 255)"); // Output: false (Octet > 255)
const p17 = document.createElement('p');
p17.textContent = 'isIP("1.2.3"): ' + isIP("1.2.3") + "(Incomplete)";
document.body.appendChild(p17);
console.log('isIP("1.2.3"): ' + isIP("1.2.3")); // Output: false (Incomplete)
// isNumeric
const p18 = document.createElement('p');
p18.textContent = 'isNumeric("123.45"): ' + isNumeric("123.45");
document.body.appendChild(p18);
console.log('isNumeric("123.45"): ' + isNumeric("123.45")); // Output: true
const p19 = document.createElement('p');
p19.textContent = 'isNumeric("12abc"): ' + isNumeric("12abc");
document.body.appendChild(p19);
console.log('isNumeric("12abc"): ' + isNumeric("12abc")); // Output: false
// isValidPassword (Min 8, 1 Upper, 1 Lower, 1 Number, 1 Symbol)
const p20 = document.createElement('p');
p20.textContent = 'isValidPassword("Pass@123"): ' + isValidPassword("Pass@123");
document.body.appendChild(p20);
console.log('isValidPassword("Pass@123"): ' + isValidPassword("Pass@123")); // Output: true
const p21 = document.createElement('p');
p21.textContent = 'isValidPassword("password"): ' + isValidPassword("password");
document.body.appendChild(p21);
console.log('isValidPassword("password"): ' + isValidPassword("password")); // Output: false (No upper, no number, no symbol)
const p22 = document.createElement('p');
p22.textContent = 'isValidPassword("PASSWORD123!"): ' + isValidPassword("PASSWORD123!");
document.body.appendChild(p22);
console.log('isValidPassword("PASSWORD123!"): ' + isValidPassword("PASSWORD123!")); // Output: false (No lower)
// isCamelCase
const p23 = document.createElement('p');
p23.textContent = 'isCamelCase("myVarName"): ' + isCamelCase("myVarName");
document.body.appendChild(p23);
console.log('isCamelCase("myVarName"): ' + isCamelCase("myVarName")); // Output: true
const p24 = document.createElement('p');
p24.textContent = 'isCamelCase("MyVar"): ' + isCamelCase("MyVar");
document.body.appendChild(p24);
console.log('isCamelCase("MyVar"): ' + isCamelCase("MyVar")); // Output: false (Must start lowercase)
// isSnakeCase
const p25 = document.createElement('p');
p25.textContent = 'isSnakeCase("my_var_name"): ' + isSnakeCase("my_var_name");
document.body.appendChild(p25);
console.log('isSnakeCase("my_var_name"): ' + isSnakeCase("my_var_name")); // Output: true
// escHTML
const p26 = document.createElement('p');
p26.textContent = 'escHTML("<script>"): ' + escHTML("<script>");
document.body.appendChild(p26);
console.log('escHTML("<script>"): ' + escHTML("<script>"));
// Output: "<script>"
// escURL
const p27 = document.createElement('p');
p27.textContent = 'escURL("hello world?"): ' + escURL("hello world?");
document.body.appendChild(p27);
console.log('escURL("hello world?"): ' + escURL("hello world?"));
// Output: "hello%20world%3F"
// capitalize
const p28 = document.createElement('p');
p28.textContent = 'capitalize("hello WORLD"): ' + capitalize("hello WORLD");
document.body.appendChild(p28);
console.log('capitalize("hello WORLD"): ' + capitalize("hello WORLD"));
// Output: "Hello world"
const p000 = document.createElement('p');
p000.textContent = '=== 🧹 Array Utilities ===';
document.body.appendChild(p000);
console.log('=== 🧹 Array Utilities ===');
// cleanArray
const p29 = document.createElement('p');
p29.textContent = 'cleanArray([1, null, "hello", undefined, "", 0]): ' + cleanArray([1, null, "hello", undefined, "", 0]);
document.body.appendChild(p29);
console.log('cleanArray([1, null, "hello", undefined, "", 0]): ' + cleanArray([1, null, "hello", undefined, "", 0]));
// Output: [1, "hello", 0] (Removes null, undefined, empty strings)
// bubbleSortASC
const p30 = document.createElement('p');
p30.textContent = 'bubbleSortASC([3, 1, 4, 2]): ' + bubbleSortASC([3, 1, 4, 2]);
document.body.appendChild(p30);
console.log('bubbleSortASC([3, 1, 4, 2]): ' + bubbleSortASC([3, 1, 4, 2]));
// Output: [1, 2, 3, 4]
// bubbleSortDESC
const p31 = document.createElement('p');
p31.textContent = 'bubbleSortDESC([3, 1, 4, 2]): ' + bubbleSortDESC([3, 1, 4, 2]);
document.body.appendChild(p31);
console.log('bubbleSortDESC([3, 1, 4, 2]): ' + bubbleSortDESC([3, 1, 4, 2]));
// Output: [4, 3, 2, 1]
// mergeArrays
const p32 = document.createElement('p');
p32.textContent = 'mergeArrays([1, 2], [3, 4]): ' + mergeArrays([1, 2], [3, 4]);
document.body.appendChild(p32);
console.log('mergeArrays([1, 2], [3, 4]): ' + mergeArrays([1, 2], [3, 4]));
// Output: [1, 2, 3, 4]
// arrayHasValue
const p33 = document.createElement('p');
p33.textContent = 'arrayHasValue([1, 2, 3], 2): ' + arrayHasValue([1, 2, 3], 2);
document.body.appendChild(p33);
console.log('arrayHasValue([1, 2, 3], 2): ' + arrayHasValue([1, 2, 3], 2));
// Output: true
// arrayRemoveDuplicates
const p34 = document.createElement('p');
p34.textContent = 'arrayRemoveDuplicates([1, 2, 2, 3]): ' + arrayRemoveDuplicates([1, 2, 2, 3]);
document.body.appendChild(p34);
console.log('arrayRemoveDuplicates([1, 2, 2, 3]): ' + arrayRemoveDuplicates([1, 2, 2, 3]));
// Output: [1, 2, 3]
// generateArray
const p35 = document.createElement('p');
p35.textContent = 'generateArray(1, 5, 1): ' + generateArray(1, 5, 1);
document.body.appendChild(p35);
console.log('generateArray(1, 5, 1): ' + generateArray(1, 5, 1));
// Output: [1, 2, 3, 4, 5]
// cloneDeepArray
const originalArr = [{"a": 1}];
const clonedArr = cloneDeepArray(originalArr);
const p36 = document.createElement('p');
p36.textContent = 'cloneDeepArray check: ' + originalArr[0] !== clonedArr[0] + ' (Different references)';
document.body.appendChild(p36);
console.log('cloneDeepArray check: ' + originalArr[0] !== clonedArr[0] + ' (Different references)');
// Output: true (Different references)
const p0000 = document.createElement('p');
p0000.textContent = '=== 📦 Object Utilities ===';
document.body.appendChild(p0000);
console.log('=== 📦 Object Utilities ===');
// safeJSONParse
const p37 = document.createElement('p');
p37.textContent = 'safeJSONParse({"a": 1}):' + safeJSONParse('{"a": 1}');
document.body.appendChild(p37);
console.log("safeJSONParse(/'{/'a/': 1}/'):" + safeJSONParse('{"a": 1}'));
// Output: {a: 1}
const p38 = document.createElement('p');
p38.textContent = "safeJSONParse('invalid'): " + safeJSONParse('invalid');
document.body.appendChild(p38);
console.log("safeJSONParse('invalid'): " + safeJSONParse('invalid'));
// Output: null (No error thrown)
// mergeObjects
const p39 = document.createElement('p');
p39.textContent = 'mergeObjects({"a": 1}, {"b": 2}): ' + mergeObjects({"a": 1}, {"b": 2});
document.body.appendChild(p39);
console.log('mergeObjects({"a": 1}, {"b": 2}): ' + mergeObjects({"a": 1}, {"b": 2}));
// Output: {a: 1, b: 2}
// cloneDeepObject
const originalObj = {"x": {"y": 1}};
const clonedObj = cloneDeepObject(originalObj);
const p40 = document.createElement('p');
p40.textContent = 'cloneDeepObject check: ' + originalObj.x !== clonedObj.x + ' (Different references)';
document.body.appendChild(p40);
console.log('cloneDeepObject check: ' + originalObj.x !== clonedObj.x + ' (Different references)');
// Output: true (Different references)
// objectHasKey
const p41 = document.createElement('p');
p41.textContent = 'objectHasKey({"a": 1}, "a"): ' + objectHasKey({"a": 1}, "a");
document.body.appendChild(p41);
console.log('objectHasKey({"a": 1}, "a"): ' + objectHasKey({"a": 1}, "a"));
// Output: true
// objectHasValue
const p42 = document.createElement('p');
p42.textContent = 'objectHasValue({"a": 1}, 1): ' + objectHasValue({"a": 1}, 1);
document.body.appendChild(p42);
console.log('objectHasValue({"a": 1}, 1): ' + objectHasValue({"a": 1}, 1));
// Output: true
const p00000 = document.createElement('p');
p00000.textContent = '=== 📅 Date & Time Utilities ===';
document.body.appendChild(p00000);
console.log('=== 📅 Date & Time Utilities ===');
const today = "Jan, 01, 2026";
const p111111 = document.createElement('p');
p111111.textContent = 'today: ' + today;
document.body.appendChild(p111111);
// NOTE: Ensure isStringAValidDate is exported in index.js if using it externally
if(isStringAValidDate) {
const p43 = document.createElement('p');
p43.textContent = 'isStringAValidDate("2023-01-01"): ' + isStringAValidDate("2023-01-01");
document.body.appendChild(p43);
console.log('isStringAValidDate("2023-01-01"): ' + isStringAValidDate("2023-01-01"));
}
// Output: true
// isSameDayName
const nextWeek = "Jan, 08, 2026";
const p1111111 = document.createElement('p');
p1111111.textContent = 'nextWeek: ' + nextWeek;
document.body.appendChild(p1111111);
const p44 = document.createElement('p');
p44.textContent = 'isSameDayName("01/01/2026", "Jan, 08, 2026"): ' + isSameDayName(today, nextWeek);
document.body.appendChild(p44);
console.log('isSameDayName("01/01/2026", "Jan, 08, 2026"): ' + isSameDayName(today, nextWeek));
// Output: true (e.g., both are Thursday)
// shortDayName
const p45 = document.createElement('p');
p45.textContent = 'shortDayName(today): ' + shortDayName(today);
document.body.appendChild(p45);
console.log('shortDayName(today): ' + shortDayName(today)); // Output: e.g., "Mon"
// fullDayName
const p46 = document.createElement('p');
p46.textContent = 'fullDayName(today): ' + fullDayName(today);
document.body.appendChild(p46);
console.log('fullDayName(today): ' + fullDayName(today)); // Output: e.g., "Monday"
// shortMonthName
const p47 = document.createElement('p');
p47.textContent = 'shortMonthName(1): ' + shortMonthName(1);
document.body.appendChild(p47);
console.log('shortMonthName(1): ' + shortMonthName(1)); // Output: "Jan"
// fullMonthName
const p48 = document.createElement('p');
p48.textContent = 'fullMonthName(1): ' + fullMonthName(1);
document.body.appendChild(p48);
console.log('fullMonthName(1): ' + fullMonthName(1)); // Output: "January"
// SeasonName
const p49 = document.createElement('p');
p49.textContent = 'SeasonName(today): ' + SeasonName(today);
document.body.appendChild(p49);
console.log('SeasonName(today): ' + SeasonName(today));
// Output: e.g., "Autumn"
// formatNumericDate
const p50 = document.createElement('p');
p50.textContent = 'formatNumericDate(today, "DD/MM/YYYY"): ' + formatNumericDate(today, "DD/MM/YYYY");
document.body.appendChild(p50);
console.log('formatNumericDate(today, "DD/MM/YYYY"): ' + formatNumericDate(today, "DD/MM/YYYY"));
// Output: e.g., "26/11/2024"
// formatShortNamedDate
const p51 = document.createElement('p');
p51.textContent = 'formatShortNamedDate(today): ' + formatShortNamedDate(today);
document.body.appendChild(p51);
console.log('formatShortNamedDate(today): ' + formatShortNamedDate(today));
// Output: e.g., "Nov 26, 2024"
// formatFullNamedDate
const p52 = document.createElement('p');
p52.textContent = 'formatFullNamedDate(today): ' + formatFullNamedDate(today);
document.body.appendChild(p52);
console.log('formatFullNamedDate(today): ' + formatFullNamedDate(today));
// Output: e.g., "November 26, 2024"
// formatTime24
const p53 = document.createElement('p');
p53.textContent = 'formatTime24(today): ', formatTime24(today);
document.body.appendChild(p53);
console.log('formatTime24(today): ', formatTime24(today));
// Output: e.g., "14: 30: 05"
// formatTime12
const p54 = document.createElement('p');
p54.textContent = 'formatTime12(today): ' + formatTime12(today);
document.body.appendChild(p54);
console.log('formatTime12(today): ' + formatTime12(today));
// Output: e.g., "02: 30: 05 PM"
// Time Math
const p55 = document.createElement('p');
p55.textContent = 'addDays(today, 5): ' + addDays(today, 5);
document.body.appendChild(p55);
console.log('addDays(today, 5): ' + addDays(today, 5));
// Output: Date 5 days from now
const p56 = document.createElement('p');
p56.textContent = 'subtractYears(today, 1): ' + subtractYears(today, 1);
document.body.appendChild(p56);
console.log('subtractYears(today, 1): ' + subtractYears(today, 1));
// Output: Date 1 year ago
// Special Days
const p57 = document.createElement('p');
p57.textContent = 'isSatOrSun(today): ' + isSatOrSun(today);
document.body.appendChild(p57);
console.log('isSatOrSun(today): ' + isSatOrSun(today)); // Boolean
const xmas = "Dec 25"; // Dec 25
const p58 = document.createElement('p');
p58.textContent = 'isChristmas(xmas): ' + isChristmas(xmas);
document.body.appendChild(p58);
console.log('isChristmas(xmas): ' + isChristmas(xmas)); // Output: true
// Thanksgiving 2026 Test
// In 2026, November 1st is a Sunday. The 4th Thursday is Nov 26th.
const thanksgiving2026 = "Nov 26, 2026";
const p59 = document.createElement('p');
p59.textContent = 'isThanksGiving(Nov 26, 2026): ' + isThanksGiving(thanksgiving2026);
document.body.appendChild(p59);
console.log('isThanksGiving(Nov 26, 2026): ' + isThanksGiving(thanksgiving2026));
// Output: true
// New Year Test
const newYear = "Jan 1, 2026"; // Jan 1st
const p60 = document.createElement('p');
p60.textContent = 'isNewYear(Jan 1, 2026): ' + isNewYear(newYear);
document.body.appendChild(p60);
console.log('isNewYear(Jan 1, 2026): ' + isNewYear(newYear));
// Output: true
// Western Easter Test (2026: April 5)
const westernEaster = "Apr 5, 2026";
const p61 = document.createElement('p');
p61.textContent = 'isWesternEaster(Apr 5, 2026): ' + isWesternEaster(westernEaster);
document.body.appendChild(p61);
console.log('isWesternEaster(Apr 5, 2026): ' + isWesternEaster(westernEaster));
// Output: true
// Eastern Easter Test (2026: April 12)
const easternEaster = "Apr 12, 2026";
const p62 = document.createElement('p');
p62.textContent = 'isEasternEaster(Apr 5, 2026): ' + isEasternEaster(easternEaster);
document.body.appendChild(p62);
console.log('isEasternEaster(Apr 12, 2026): ' + isEasternEaster(easternEaster));
// Output: true
const p000000 = document.createElement('p');
p000000.textContent = '=== 📱 Devices Recognition Utilities ===';
document.body.appendChild(p000000);
console.log('=== 📱 Devices Recognition Utilities ===');
// NOTE: These tests rely on global browser objects (window, navigator) and will likely return 'false' or 'null' if run in a pure Node.js environment.
const p63 = document.createElement('p');
p63.textContent = 'isMobile(): ' + isMobile();
document.body.appendChild(p63);
console.log('isMobile(): ' + isMobile());
// Output: true (if running on a mobile device) or false (if running on desktop/node)
const p64 = document.createElement('p');
p64.textContent = 'isAndroidMobile(): ' + isAndroidMobile();
document.body.appendChild(p64);
console.log('isAndroidMobile(): ' + isAndroidMobile());
// Output: true (if running on an Android mobile phone) or false
const p65 = document.createElement('p');
p65.textContent = 'isHuaweiMobile(): ' + isHuaweiMobile();
document.body.appendChild(p65);
console.log('isHuaweiMobile(): ' + isHuaweiMobile());
// Output: true (if running on a Huawei mobile phone) or false
const p66 = document.createElement('p');
p66.textContent = 'isIPhone(): ' + isIPhone();
document.body.appendChild(p66);
console.log('isIPhone(): ' + isIPhone());
// Output: true (if running on an iPhone) or false
const p67 = document.createElement('p');
p67.textContent = 'isMobileLandscape(): ' + isMobileLandscape();
document.body.appendChild(p67);
console.log('isMobileLandscape(): ' + isMobileLandscape());
// Output: true (if mobile and width > height) or false
const p68 = document.createElement('p');
p68.textContent = 'isMobilePortrait(): ' + isMobilePortrait();
document.body.appendChild(p68);
console.log('isMobilePortrait(): ' + isMobilePortrait());
// Output: true (if mobile and width <= height) or false
const p69 = document.createElement('p');
p69.textContent = 'isTablet(): ' + isTablet();
document.body.appendChild(p69);
console.log('isTablet(): ' + isTablet());
// Output: true (if running on a tablet device) or false
const p70 = document.createElement('p');
p70.textContent = 'isAndroidTablet(): ' + isAndroidTablet();
document.body.appendChild(p70);
console.log('isAndroidTablet(): ' + isAndroidTablet());
// Output: true (if running on an Android tablet) or false
const p71 = document.createElement('p');
p71.textContent = 'isHuaweiTablet(): ' + isHuaweiTablet();
document.body.appendChild(p71);
console.log('isHuaweiTablet(): ' + isHuaweiTablet());
// Output: true (if running on a Huawei tablet) or false
const p72 = document.createElement('p');
p72.textContent = 'isIPad(): ' + isIPad();
document.body.appendChild(p72);
console.log('isIPad(): ' + isIPad());
// Output: true (if running on an iPad) or false
const p73 = document.createElement('p');
p73.textContent = 'isTabletLandscape(): ' + isTabletLandscape();
document.body.appendChild(p73);
console.log('isTabletLandscape(): ' + isTabletLandscape());
// Output: true (if tablet and width > height) or false
const p74 = document.createElement('p');
p74.textContent = 'isTabletPortrait(): ' + isTabletPortrait();
document.body.appendChild(p74);
console.log('isTabletPortrait(): ' + isTabletPortrait());
// Output: true (if tablet and width <= height) or false
const p75 = document.createElement('p');
p75.textContent = 'isDesktop(): ' + isDesktop();
document.body.appendChild(p75);
console.log('isDesktop(): ' + isDesktop());
// Output: true (if not mobile and not tablet) or false
const p76 = document.createElement('p');
p76.textContent = 'isIOS(): ' + isIOS();
document.body.appendChild(p76);
console.log('isIOS(): ' + isIOS());
// Output: true (if running on iOS/iPadOS) or false
const p77 = document.createElement('p');
p77.textContent = 'isMacOS(): ' + isMacOS();
document.body.appendChild(p77);
console.log('isMacOS(): ' + isMacOS());
// Output: true (if running on macOS) or false
const p78 = document.createElement('p');
p78.textContent = 'isWindows(): ' + isWindows();
document.body.appendChild(p78);
console.log('isWindows(): ' + isWindows());
// Output: true (if running on Windows OS) or false
const p79 = document.createElement('p');
p79.textContent = 'isWindows7(): ' + isWindows7();
document.body.appendChild(p79);
console.log('isWindows7(): ' + isWindows7());
// Output: true (if running on Windows 7) or false
const p80 = document.createElement('p');
p80.textContent = 'isWindows10(): ' + isWindows10();
document.body.appendChild(p80);
console.log('isWindows10(): ' + isWindows10());
// Output: true (if running on Windows 10) or false
const p81 = document.createElement('p');
p81.textContent = 'isWindows11(): ' + isWindows11() + ' Note: relies on Win 10 UA string)';
document.body.appendChild(p81);
console.log('isWindows11(): ' + isWindows11());
// Output: true (if running on Windows 11 - Note: relies on Win 10 UA string) or false
const p82 = document.createElement('p');
p82.textContent = 'isLinux(): ' + isLinux();
document.body.appendChild(p82);
console.log('isLinux(): ' + isLinux());
// Output: true (if running on Linux) or false
const p0000000 = document.createElement('p');
p0000000.textContent = '=== 🌐 Browsers Recognition Utilities ===';
document.body.appendChild(p0000000);
console.log('=== 🌐 Browsers Recognition Utilities ===');
// NOTE: These tests rely on global browser objects (navigator) and will likely return 'false' if run in a pure Node.js environment.
const p83 = document.createElement('p');
p83.textContent = 'isWebkit(): ' + isWebkit();
document.body.appendChild(p83);
console.log('isWebkit(): ' + isWebkit());
// Output: true (if browser uses WebKit engine) or false
const p84 = document.createElement('p');
p84.textContent = 'isChrome(): ' + isChrome();
document.body.appendChild(p84);
console.log('isChrome(): ' + isChrome());
// Output: true (if browser is Google Chrome) or false
const p85 = document.createElement('p');
p85.textContent = 'isEdge(): ' + isEdge();
document.body.appendChild(p85);
console.log('isEdge(): ' + isEdge());
// Output: true (if browser is Microsoft Edge) or false
const p86 = document.createElement('p');
p86.textContent = 'isFirefox(): ' + isFirefox();
document.body.appendChild(p86);
console.log('isFirefox(): ' + isFirefox());
// Output: true (if browser is Mozilla Firefox) or false
const p87 = document.createElement('p');
p87.textContent = 'isOprea(): ' + isOprea();
document.body.appendChild(p87);
console.log('isOprea(): ' + isOprea());
// Output: true (if browser is Opera) or false
const p88 = document.createElement('p');
p88.textContent = 'isBrave(): ' + isBrave();
document.body.appendChild(p88);
console.log('isBrave(): ' + isBrave());
// Output: true (if browser is Brave) or false
const p89 = document.createElement('p');
p89.textContent = 'isInternetExplorer(): ' + isInternetExplorer();
document.body.appendChild(p89);
console.log('isInternetExplorer(): ' + isInternetExplorer());
// Output: true (if browser is IE 11 or older) or false
const p00000000 = document.createElement('p');
p00000000.textContent = '=== 🛠️ Helper Utilities ===';
document.body.appendChild(p00000000);
console.log('=== 🛠️ Helper Utilities ===');
// fahrenheitToCelsius
const p90 = document.createElement('p');
p90.textContent = 'fahrenheitToCelsius(32): ' + fahrenheitToCelsius(32);
document.body.appendChild(p90);
console.log('fahrenheitToCelsius(32): ' + fahrenheitToCelsius(32));
// Output: 0
// celsiusToFahrenheit
const p91 = document.createElement('p');
p91.textContent = 'celsiusToFahrenheit(0): ' + celsiusToFahrenheit(0);
document.body.appendChild(p91);
console.log('celsiusToFahrenheit(0): ' + celsiusToFahrenheit(0));
// Output: 32
// delay
const p92 = document.createElement('p');
function print() {
p92.textContent = "delay: Waiting 3 seconds...Then Print " + sum(10, 20, 5, 5);
}
delay(print, 3000);
document.body.appendChild(p92);
//console.log("delay: Waiting 3 seconds...Then Print " + delay(print, 3000));
🌍 Roadmap
- Add TypeScript Support.
- Add More Utilities Functions.
- Improve Documentation.
🤝 Contributing
Contributions are always welcome! Please send me an email.
📄 License
This Project Is Licensed Under The MIT License. See The license.txt File For Details.
❤️ Support
If You Like This Package, Buy Me A Coffee!
