Any and all donations to help keep active development and the lights on are more than welcome.
- Added VirtualDebug
 - Various bug fixes and documentation generation bug fix
 - removed 
AttachKeysToVec3()// TypeScript only - removed 
VisualDebug()// TypeScript only (useattachDebugfor JS projects) - Optimised various functions and clean up
 - Added 
hexToColor(THREE.Color) - Added 
doesUrlKeyExist(string) - Added 
getUrlKeyValue(string) - Added 
rgbToHex3 - Added 
convert255(124) - Updated 
fetchJson(string) - Added 
getDeviceType() 
You're looking for aftc.js. Visit: https://github.com/DarceyLloyd/AFTC.js
npm i aftc-modulesinertiaTo(current, target, amount)arrayClear(arr)arrayContains(needle, haystack)arrayEmpty(arr)arrayGetMax(arr)arrayGetMin(arr)arrayRemoveIndex(arr, index)arrayRemoveValue(arr, value)arrayShuffle(arr)arrayShuffle2(arr)isArrayInString(input, arr)isInArray(needle, haystack)isStringInArray(needle, haystack)getBrowser()getBrowserX()getBrowserY()isInViewport(el)argsToObject({object}, {object}, strict)boolToInt(bool)boolToString(bool)boolToYesNo(bool)degToRad(input)hexToRgb(hex)numToHex(num)objectToObject({object}, {object}, strict)radToDeg(input)rgbToHex(r, g, b)rgbToHex2(r, g, b)rgbToHex3(r, g, b)stringToBool(str)getCookie(name)listCookies()setCookie(name, cvalue, exdays)getDaysBetween(startDateTime, endDateTime)getMySQLDateTimeString()getUKDate(dte, separator)getUKDateFromDbDateTime(dbDateString, separator)getUKDateTime(dte, separator)getUkDateTimeFromDbDateTime(dte, separator)getUSDate(dte, separator)appendTo(elementOrId, msg, endOfLine)attachDebug(no, position, ele)debugTo(index, str)log(arg)logDisable()logEnable()Logger()logTo(elementOrId, msg, append, endOfLine)warn(arg)getDeviceType()getOS()isAndroid()isChrome()isEdge()isFireFox()isIOS()isMobile()isSafari()isTouchDevice()getElementPos(ele)getElementPosition(el)getElementPos(el)hasClass(elementOrId, ele)isDOM(obj)isElement(ele)isElement2(ele)setHTML(elementOrId, str, mode)onReady(fn)wordCountFilter(str, maxWords)setOptionSelectedIndex(selectElement, selectedValue)imageToCanvas(url)fetchHtml(url)fetchJson(url)loadAndAttachImage(imgElement, src)loadScript(src, onComplete, onProgress)promiseLoadCss(href)promiseLoadImage(ele, src)promiseLoadJson(url)promiseLoadScript(src)getRandomBoolean()getRandomFloat(min, max)getRandomInt(min, max)getRange(value1, value2)isEven(n)isOdd(n)normaliseRange(min, max, v)parseArrayToFloat(arr)parseArrayToInt(arr)roundTo(v, dec)getGUID()getUID(len)isAlphaNumeric(v)isArray(input)isBool(input)isBoolean(input)isNumber(n)isNumeric(n)MouseScrollHandler(onScrollUp, onScrollDown)getObjectPropByKey({object}, key)cutStringTo(str, len)escapeHTML(str)getAnchor(url)getCleanJSONString(s)getFileExtension(str)getLastPartOfUrl(url)getRandomString(len)getStringBetween(source, start, end)getStringBetween2(source, start, end)getWordCount(str)inString(needle, haystack)isInString(needle, haystack)lTrimBy(str, by)regExReplaceAll(needle, rep, haystack)removeFileFromPath(path)replaceAll(needle, replace, haystack)replaceDoubleBackSlash(str, rep)replaceDoubleForwardSlash(str, rep)rTrimBy(str, trimBy)trimStringBy(str, trimBy)ucFirst(s)SwipeHandler({object})getRoute(url)promiseAttachVideo(video, src)promiseVideoEnd(video)
Calculates the target value of inertia in a loop/requestAnimationFrame from one value to another at speed.
- current
- Type: 
Number - Required: 
true - Info: Current value.
 
 - Type: 
 - target
- Type: 
Number - Required: 
true - Info: Value to reach.
 
 - Type: 
 - amount
- Type: 
Number - Required: 
true - Info: Inertia speed (dec/inc speed).
 
 - Type: 
 
- Type: 
Number 
let newX = inertiaTo(curX, targetX, 0.5);Clears an array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to clear / empty.
 
 - Type: 
 
arrayClear(myArray);Finds a needle in a haystack.
- needle
- Type: 
string - Required: 
true - Default: 
null - Info: What you are looking for.
 
 - Type: 
 - haystack
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to search.
 
 - Type: 
 
Clears an array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to clear / empty.
 
 - Type: 
 
arrayEmpty(myArray);Gets the maximum value from the supplied array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to get the maximum value from.
 
 - Type: 
 
- Type: 
Number 
let max = arrayGetMax(myArray);Gets the minimum value from the supplied array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to get the minimum value from.
 
 - Type: 
 
- Type: 
Number 
let min = arrayGetMin(myArray);Removes an index from the supplied array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to remove the index from.
 
 - Type: 
 - index
- Type: 
number - Required: 
true - Default: 
null - Info: The index which you want to remove.
 
 - Type: 
 
- Type: 
Array 
let newArray = arrayRemoveIndex(arr, index);Removes a value from the supplied array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to remove the value from.
 
 - Type: 
 - value
- Type: 
string||number - Required: 
true - Default: 
null - Info: The value which you want to remove from the array.
 
 - Type: 
 
- Type: 
Array 
let newArray = arrayRemoveValue(arr, value);Shuffles / Randomizes an array.
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to shuffle.
 
 - Type: 
 
- Type: 
Array 
let shuffledArray = arrayShuffle(myArray);Shuffles / Randomizes an array (method 2).
- arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to shuffle.
 
 - Type: 
 
- Type: 
Array 
let shuffledArray = arrayShuffle2(myArray);Searches if any string from an array is present in an input string.
- input
- Type: 
string - Required: 
true - Default: 
null - Info: String you want to look for matches in.
 
 - Type: 
 - arr
- Type: 
array - Required: 
true - Default: 
null - Info: The array of strings you want to search for in the input string.
 
 - Type: 
 
- Type: 
Boolean 
let found = isArrayInString("hello world", ["world", "foo"]); // trueSearches an array for a value.
- needle
- Type: 
* - Required: 
true - Default: 
null - Info: What you are looking for.
 
 - Type: 
 - haystack
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to search.
 
 - Type: 
 
- Type: 
Boolean 
let found = isInArray(needle, haystack);Searches an array for a string.
- needle
- Type: 
string - Required: 
true - Default: 
null - Info: String you are looking for.
 
 - Type: 
 - haystack
- Type: 
array - Required: 
true - Default: 
null - Info: The array you want to search.
 
 - Type: 
 
- Type: 
Boolean 
let found = isStringInArray(needle, haystack);Gets the name of the browser you are using (opera | chrome | safari | firefox | msie | trident | edge).
- Type: 
String 
let browser = getBrowser();Gets the viewport width.
- Type: 
Number 
let x = getBrowserX();Gets the viewport height.
- Type: 
Number 
let y = getBrowserY();Checks whether an element is in the viewport.
- el
- Type: 
Element - Required: 
true - Default: 
null - Info: The element you want to check.
 
 - Type: 
 
- Type: 
Boolean 
let isInView = isInViewport(myElement);Parses arguments to a destination object with strict or relaxed assigning features. Good for handling default options in functions or classes.
- src
- Type: 
Object - Required: 
true - Default: 
null - Info: The source object (e.g., 
arguments[0]). 
 - Type: 
 - dest
- Type: 
Object - Required: 
true - Default: 
null - Info: The destination object to assign properties to.
 
 - Type: 
 - strict
- Type: 
Boolean - Required: 
false - Default: 
true - Info: If 
true, warns about properties insrcthat don't exist indest. 
 - Type: 
 
- Type: 
Object(the modified destination object) 
/* Class based example */
class MyApp {
    constructor() {
        this.appArgs = { a: 0, b: 0 };
        argsToObject(arguments[0], this.appArgs, true);
    }
}
/*
 * Instantiation of your class.
 * NOTE: 'c' will trigger a warning if strict mode is enabled,
 * as it's not a defined property in this.appArgs.
 */
new MyApp({ a: 1, b: 3, c: 4 });Converts a boolean to an integer (1 or 0).
- bool
- Type: 
Boolean - Required: 
true - Default: 
null - Info: The boolean you wish to convert.
 
 - Type: 
 
- Type: 
Number 
let intValue = boolToInt(true); // 1Converts a boolean to a string ('true' or 'false').
- bool
- Type: 
Boolean - Required: 
true - Default: 
null - Info: The boolean you wish to convert.
 
 - Type: 
 
- Type: 
String 
let strBool = boolToString(false); // 'false'Converts a boolean to a string ('yes' or 'no').
- bool
- Type: 
Boolean - Required: 
true - Default: 
null - Info: The boolean you wish to convert.
 
 - Type: 
 
- Type: 
String 
let answer = boolToYesNo(true); // 'yes'Converts degrees to radians.
- input
- Type: 
Number - Required: 
true - Default: 
null - Info: The degree value to convert.
 
 - Type: 
 
- Type: 
Number 
let radians = degToRad(180);Converts a hex color string to an RGB object.
- hex
- Type: 
String - Required: 
true - Default: 
null - Info: Hex color string (e.g., '#FFCC00').
 
 - Type: 
 
- Object or 
nullif invalid.- r: 
Number - g: 
Number - b: 
Number 
 - r: 
 
let rgb = hexToRgb('#FFCC00'); // { r: 255, g: 204, b: 0 }Converts a number to a hexadecimal string.
- num
- Type: 
Number - Required: 
true - Default: 
null - Info: The number you want to convert.
 
 - Type: 
 
- Type: 
String 
let hex = numToHex(255); // 'ff'Parses properties from a source object to a destination object with strict or relaxed assigning features.
- src
- Type: 
Object - Required: 
true - Default: 
null - Info: The source object.
 
 - Type: 
 - dest
- Type: 
Object - Required: 
true - Default: 
null - Info: The destination object.
 
 - Type: 
 - strict
- Type: 
Boolean - Required: 
false - Default: 
true - Info: If 
true, warns about properties insrcthat don't exist indest. 
 - Type: 
 
- Type: 
Object(the modified destination object) 
/* Class based example */
class MyClass {
    constructor(options) {
        this.config = { a: 0, b: 0 };
        objectToObject(options, this.config, true);
    }
}
/*
 * Instantiation of your class.
 * NOTE: 'c' will trigger a warning if strict mode is enabled.
 */
new MyClass({ a: 1, b: 3, c: 4 });Converts radians to degrees.
- input
- Type: 
Number - Required: 
true - Default: 
null - Info: The radian value to convert.
 
 - Type: 
 
- Type: 
Number 
let degrees = radToDeg(Math.PI); // 180Converts RGB values to a hex color string.
- r
- Type: 
Number - Required: 
true - Info: Red value (0-255).
 
 - Type: 
 - g
- Type: 
Number - Required: 
true - Info: Green value (0-255).
 
 - Type: 
 - b
- Type: 
Number - Required: 
true - Info: Blue value (0-255).
 
 - Type: 
 
- Type: 
String 
let hex = rgbToHex(255, 100, 55); // '#ff6437'Converts RGB values to a hex color string (Method 2).
- r
- Type: 
Number - Required: 
true - Info: Red value (0-255).
 
 - Type: 
 - g
- Type: 
Number - Required: 
true - Info: Green value (0-255).
 
 - Type: 
 - b
- Type: 
Number - Required: 
true - Info: Blue value (0-255).
 
 - Type: 
 
- Type: 
String 
let hex = rgbToHex2(255, 100, 55);Converts RGB values to a hex color string (Method 3).
- r
- Type: 
Number - Required: 
true - Info: Red value (0-255).
 
 - Type: 
 - g
- Type: 
Number - Required: 
true - Info: Green value (0-255).
 
 - Type: 
 - b
- Type: 
Number - Required: 
true - Info: Blue value (0-255).
 
 - Type: 
 
- Type: 
String 
let hex = rgbToHex3(255, 100, 55);Converts a string to a boolean. Recognizes 'true', 'yes', 'y', '1' as true.
- str
- Type: 
String - Required: 
true - Default: 
null - Info: The string value you want to convert.
 
 - Type: 
 
- Type: 
Boolean 
let answer1 = stringToBool('yes');   // true
let answer2 = stringToBool('y');     // true
let answer3 = stringToBool('1');     // true
let answer4 = stringToBool('no');    // false
let answer5 = stringToBool('n');     // false
let answer6 = stringToBool('0');     // falseFetches a cookie by name.
- name
- Type: 
String - Required: 
true - Info: The name of the cookie to retrieve.
 
 - Type: 
 
- Type: 
String(the cookie value, or an empty string if not found). 
let email = getCookie('email');Lists all available cookies as an object.
console.log(listCookies());Sets a cookie.
- name
- Type: 
String - Required: 
true - Info: The name of the cookie.
 
 - Type: 
 - cvalue
- Type: 
String - Required: 
true - Info: The value to store in the cookie.
 
 - Type: 
 - exdays
- Type: 
Number - Required: 
true - Info: The number of days until the cookie expires.
 
 - Type: 
 
let name = 'email';
let value = '[email protected]';
let lifeInDays = 30;
setCookie(name, value, lifeInDays);Gets the number of days between two dates.
- startDateTime
- Type: 
Date - Required: 
true - Info: The start date.
 
 - Type: 
 - endDateTime
- Type: 
Date - Required: 
true - Info: The end date.
 
 - Type: 
 
- Type: 
Number 
/* NOTE: Month is indexed at 0 */
let startDateTime = new Date(2020, 2, 26); // March 26, 2020
let endDateTime = new Date(2020, 3, 26); // April 26, 2020
let days = getDaysBetween(startDateTime, endDateTime);Gets the current date and time as a MySQL-compatible DATETIME string.
- Type: 
String 
let dte = getMySQLDateTimeString(); // e.g., '2023-10-27 10:30:00'Gets a UK-formatted date string (DD-MM-YYYY) from a supplied date.
- dte
- Type: 
Date||String - Required: 
true - Info: The date object or string.
 
 - Type: 
 - separator
- Type: 
String - Required: 
false - Default: 
- - Info: The separator for date parts.
 
 - Type: 
 
- Type: 
String 
let ukDate = getUKDate(new Date(), '/'); // e.g., '27/10/2023'Gets a UK-formatted date string from a database datetime string.
- dbDateString
- Type: 
String - Required: 
true - Info: A datetime string from a database (e.g., 'YYYY-MM-DD HH:MM:SS').
 
 - Type: 
 - separator
- Type: 
String - Required: 
false - Default: 
- - Info: The separator for date parts.
 
 - Type: 
 
- Type: 
String 
let ukDate = getUKDateFromDbDateTime('2023-10-27 10:30:00'); // '27-10-2023'Gets a UK-formatted date and time string from a supplied date.
- dte
- Type: 
Date||String - Required: 
true - Info: The date object or string.
 
 - Type: 
 - separator
- Type: 
String - Required: 
false - Default: 
- - Info: The separator for date parts.
 
 - Type: 
 
- Type: 
String 
let ukDateTime = getUKDateTime(new Date(), '/'); // e.g., '27/10/2023 10:30:00'Gets a UK-formatted date and time string from a database datetime string.
- dte
- Type: 
String - Required: 
true - Info: A datetime string from a database.
 
 - Type: 
 - separator
- Type: 
String - Required: 
false - Default: 
- - Info: The separator for date parts.
 
 - Type: 
 
- Type: 
String 
let ukDateTime = getUkDateTimeFromDbDateTime('2023-10-27 10:30:00'); // '27-10-2023 10:30:00'Gets a US-formatted date string (MM-DD-YYYY) from a supplied date.
- dte
- Type: 
Date - Required: 
true - Info: The date object.
 
 - Type: 
 - separator
- Type: 
String - Required: 
false - Default: 
- - Info: The separator for date parts.
 
 - Type: 
 
- Type: 
String 
let usDate = getUSDate(new Date(), '/'); // e.g., '10/27/2023'Appends a string to an element, with or without a <br> tag.
- elementOrId
- Type: 
Element||String - Required: 
true - Info: The element or its ID.
 
 - Type: 
 - msg
- Type: 
String - Required: 
true - Info: The string to append.
 
 - Type: 
 - endOfLine
- Type: 
String - Required: 
false - Default: 
<br> - Info: The string to append after the message. Set to 
''for no line break. 
 - Type: 
 
appendTo('my-div', 'Hello World', '');Displays an on-screen debug panel to watch variables in real-time. Excellent for debugging animations, key events, etc. Click a row to copy its value. Use with debugTo.
- no
- Type: 
Number - Required: 
true - Info: The number of debug rows to create.
 
 - Type: 
 - position
- Type: 
String('tl', 'top left', 'tr', 'top right', 'bl', 'btm left', 'br', 'btm right') - Required: 
false - Default: 
'top left' - Info: Position of the debug panel.
 
 - Type: 
 - ele
- Type: 
Element - Required: 
false - Default: 
document.body - Info: The element to which the debug panel will be appended.
 
 - Type: 
 
attachDebug(3);
debugTo(0, 'hello world 1');
debugTo(1, 'hello world 2');
debugTo(2, 'hello world 3');Writes a string to a specific row in the on-screen debug panel.
- index
- Type: 
Number - Required: 
true - Info: The debug row index (0-based) to write to.
 
 - Type: 
 - str
- Type: 
String - Required: 
true - Info: The string to display.
 
 - Type: 
 
// Assumes attachDebug(3) has been called
function onAnimate() {
    let x = getPositionX();
    debugTo(0, `Position X: ${x}`);
    requestAnimationFrame(onAnimate);
}A shortcut for console.log.
- arg
- Type: 
* - Required: 
true - Info: The argument to pass to 
console.log. 
 - Type: 
 
log('Once you use me, you will never stop using me');
let a = 4;
log('a = ' + a);
log(`a = ${a}`);Disables log() globally. Useful for keeping log statements in code without outputting to the console in production.
log('You will see this in console');
logDisable();
log('You wont see this in console');Enables log() globally if it has been disabled.
log('You will see this in console');
logDisable();
log('You wont see this in console');
logEnable();
log('You will see this in console');A class-based logger that can be enabled/disabled on a per-instance or global basis.
log(message)warn(message)error(message)enable()disable()enableAll()disableAll()
class MyComponent {
    constructor() {
        this.logger = new Logger();
        this.logger.log('This will not show by default.');
        this.logger.enable();
        this.logger.log('Hello from MyComponent!');
        this.logger.warn('This is a warning.');
    }
}Sets or appends a string to an element's content.
- elementOrId
- Type: 
Element||String - Required: 
true - Info: The element or its ID.
 
 - Type: 
 - msg
- Type: 
String - Required: 
true - Info: The string to display.
 
 - Type: 
 - append
- Type: 
Boolean - Required: 
false - Default: 
false - Info: If 
true, appends the message. Iffalse, overwrites existing content. 
 - Type: 
 - endOfLine
- Type: 
String - Required: 
false - Default: 
'' - Info: String to add after the message, e.g., 
<br>. 
 - Type: 
 
// Overwrite content
logTo('my-div', 'First line.');
// Append content with a line break
logTo('my-div', 'Second line.', true, '<br>');A shortcut for console.warn.
- arg
- Type: 
* - Required: 
true - Info: The argument to pass to 
console.warn. 
 - Type: 
 
warn('This is an important warning.');Returns the device type: 'mobile', 'tablet', or 'desktop'.
- Type: 
String 
let deviceType = getDeviceType();Gets the operating system.
- Type: 
String('Mac OS', 'iOS', 'Windows', 'Android', 'Linux', or 'Unknown') 
let os = getOS();Detects if the OS is Android.
- Type: 
Boolean 
let test = isAndroid();Detects if the browser is Chrome.
- Type: 
Boolean 
let test = isChrome();Detects if the browser is Edge.
- Type: 
Boolean 
let test = isEdge();Detects if the browser is Firefox.
- Type: 
Boolean 
let test = isFireFox();Detects if the OS is iOS.
- Type: 
Boolean 
let test = isIOS();Detects if the device is a mobile phone (based on user agent).
- Type: 
Boolean 
let mobile = isMobile();Detects if the browser is Safari.
- Type: 
Boolean 
let test = isSafari();Returns a boolean indicating if the device is touch-enabled.
- Type: 
Boolean 
const isTouch = isTouchDevice();Gets an element's position relative to the document.
- el
- Type: 
Element - Required: 
true - Info: The element to get the position of.
 
 - Type: 
 
- Object
- left: 
Number(x position) - top: 
Number(y position) 
 - left: 
 
let pos = getElementPos(myElement);
console.log(pos.left, pos.top);Gets an element's position. (Alias for getElementPos)
- el
- Type: 
Element - Required: 
true - Info: The element to get the position of.
 
 - Type: 
 
- Object with 
leftandtopproperties. 
let pos = getElementPosition(myElement);Checks if an element has a specific CSS class.
- elementOrId
- Type: 
Element||String - Required: 
true - Info: The element or its ID.
 
 - Type: 
 - className
- Type: 
String - Required: 
true - Info: The class name to check for.
 
 - Type: 
 
- Type: 
Boolean 
let classAttached = hasClass('my-div', 'selected');Checks if an object is an HTMLElement.
- obj
- Type: 
Element||Object - Required: 
true - Info: The object to check.
 
 - Type: 
 
- Type: 
Boolean 
let result = isDOM(myElement);Checks if an object is an HTMLElement.
- ele
- Type: 
Element||Object - Required: 
true - Info: The object to check.
 
 - Type: 
 
- Type: 
Boolean 
let result = isElement(myElement);Checks if an object is an HTMLElement (Method 2).
- ele
- Type: 
Element||Object - Required: 
true - Info: The object to check.
 
 - Type: 
 
- Type: 
Boolean 
let result = isElement2(myElement);Sets an element's HTML content.
- elementOrId
- Type: 
Element||String - Required: 
true - Info: The element or its ID.
 
 - Type: 
 - str
- Type: 
String||Number - Required: 
true - Info: The content to put into the element.
 
 - Type: 
 - mode
- Type: 
String('set' | 'append' | 'prepend') - Required: 
false - Default: 
'set' - Info: The method for setting the HTML.
 
 - Type: 
 
setHTML('my-element-id', 'hello world'); // Overwrites
setHTML(myElement, '... and goodbye', 'append'); // AppendsExecutes a function when the DOM is fully loaded and ready.
- fn
- Type: 
Function - Required: 
true - Info: The function to execute.
 
 - Type: 
 
onReady(() => {
	/* DOM is ready, do your thing */
});Truncates a string to a maximum number of words.
- str
- Type: 
String - Required: 
true 
 - Type: 
 - maxWords
- Type: 
Number - Required: 
true 
 - Type: 
 
- Type: 
String 
let source = "This is a very long sentence that needs to be shortened.";
let limitedSentence = wordCountFilter(source, 5); // "This is a very long..."Sets the selected option of an HTML <select> element by its value.
- selectElement
- Type: 
HTMLSelectElement - Required: 
true 
 - Type: 
 - selectedValue
- Type: 
String - Required: 
true 
 - Type: 
 
const mySelect = document.getElementById('my-select');
setOptionSelectedIndex(mySelect, 'option-value-2');Loads an image and draws it onto a new canvas of matching dimensions.
- url
- Type: 
String - Required: 
true - Info: Path/URL to the image.
 
 - Type: 
 
- Type: 
Promise<HTMLCanvasElement> 
async function processImage() {
    try {
        let canvas = await imageToCanvas('./assets/photo.webp');
        document.body.appendChild(canvas);
    } catch (e) {
        console.error("Failed to load image to canvas:", e);
    }
}Fetches an HTML file and returns its content as a string.
- url
- Type: 
String - Required: 
true - Info: Path/URL to the file.
 
 - Type: 
 
- Type: 
Promise<String> 
let data = await fetchHtml('./pages/modal-user-content.html');Fetches a JSON file and returns it as a parsed object.
- url
- Type: 
String - Required: 
true - Info: Path/URL to the file.
 
 - Type: 
 
- Type: 
Promise<Object> 
let data = await fetchJson('./data/config.json');Loads an image into an <img> element.
- imgElement
- Type: 
HTMLImageElement - Required: 
true - Info: The 
<img>element to load the image into. 
 - Type: 
 - src
- Type: 
String - Required: 
true - Info: Path/URL to the image file.
 
 - Type: 
 
- Type: 
Promise<void> 
const imgElement1 = document.getElementById('my-image');
loadAndAttachImage(imgElement1, './assets/images/products/001.jpg')
    .then(() => { console.log('Image loaded and attached'); })
    .catch((e) => { console.error(e); });Loads a JavaScript file and attaches it to the document's <head>.
- src
- Type: 
String - Required: 
true - Info: Path/URL to the JS file.
 
 - Type: 
 - onComplete
- Type: 
Function - Required: 
false - Info: Callback on successful load.
 
 - Type: 
 - onProgress
- Type: 
Function - Required: 
false - Info: On-progress callback (if supported by the request).
 
 - Type: 
 
loadScript('./include/js/extra-script.js', () => {
    console.log('Script loaded!');
});Loads a CSS file and attaches it to the document's <head>.
- href
- Type: 
String - Required: 
true - Info: Path/URL to the CSS file.
 
 - Type: 
 
- Type: 
Promise<void> 
promiseLoadCss('./include/css/extra-style.css')
    .then(() => { console.log('CSS loaded'); })
    .catch((e) => { console.error(e); });Loads an image into an <img> element via a Promise.
- ele
- Type: 
HTMLImageElement - Required: 
true - Info: The 
<img>element to load the image into. 
 - Type: 
 - src
- Type: 
String - Required: 
true - Info: Path/URL to the image file.
 
 - Type: 
 
- Type: 
Promise<void> 
const imgElement1 = document.getElementById('my-image');
promiseLoadImage(imgElement1, './assets/images/products/001.jpg')
    .then(() => { console.log('Image loaded'); })
    .catch((e) => { console.error(e); });Loads a JSON file and returns its content via a Promise.
- url
- Type: 
String - Required: 
true - Info: Path/URL to the JSON file.
 
 - Type: 
 
- Type: 
Promise<Object> 
promiseLoadJson('./data/config.json')
    .then((data) => { console.log(data); })
    .catch((e) => { console.error(e); });Loads a JavaScript file and attaches it to the document's <head> via a Promise.
- src
- Type: 
String - Required: 
true - Info: Path/URL to the JS file.
 
 - Type: 
 
- Type: 
Promise<void> 
promiseLoadScript('./includes/js/onDemandFile.js')
    .then(() => { console.log('Script loaded and attached'); })
    .catch((e) => { console.error(e); });Returns a random boolean (true or false).
- Type: 
Boolean 
let randomBoolean = getRandomBoolean();Returns a random floating-point number between two values.
- min
- Type: 
Number - Required: 
true - Info: Minimum value.
 
 - Type: 
 - max
- Type: 
Number - Required: 
true - Info: Maximum value.
 
 - Type: 
 
- Type: 
Number 
let randomFloat = getRandomFloat(1.4, 42.232);Returns a random integer between two values (inclusive).
- min
- Type: 
Number - Required: 
true - Info: Minimum value.
 
 - Type: 
 - max
- Type: 
Number - Required: 
true - Info: Maximum value.
 
 - Type: 
 
- Type: 
Number 
let randomInt = getRandomInt(0, 100);Returns the absolute difference (range) between two numbers.
- value1
- Type: 
Number - Required: 
true 
 - Type: 
 - value2
- Type: 
Number - Required: 
true 
 - Type: 
 
- Type: 
Number 
let range = getRange(10, -10); // 20Checks if a number is even.
- n
- Type: 
Number - Required: 
true - Info: The number to check.
 
 - Type: 
 
- Type: 
Boolean 
let even = isEven(4); // trueChecks if a number is odd.
- n
- Type: 
Number - Required: 
true - Info: The number to check.
 
 - Type: 
 
- Type: 
Boolean 
let odd = isOdd(3); // trueNormalizes a value to a 0-1 range based on a min/max scale.
- min
- Type: 
Number - Required: 
true - Info: The minimum value of the range (maps to 0).
 
 - Type: 
 - max
- Type: 
Number - Required: 
true - Info: The maximum value of the range (maps to 1).
 
 - Type: 
 - v
- Type: 
Number - Required: 
true - Info: The value to normalize.
 
 - Type: 
 
- Type: 
Number 
let n1 = normaliseRange(0, 100, 50);  // 0.5
let n2 = normaliseRange(0, 100, 200); // 1 (clamped)
let n3 = normaliseRange(0, 100, -50); // 0 (clamped)Parses each item in an array to a float.
- arr
- Type: 
Array - Required: 
true - Info: The array to parse.
 
 - Type: 
 
- Type: 
Array 
let floatParsedArray = parseArrayToFloat(['1.1', '2.2', '3']); // [1.1, 2.2, 3]Parses each item in an array to an integer.
- arr
- Type: 
Array - Required: 
true - Info: The array to parse.
 
 - Type: 
 
- Type: 
Array 
let intParsedArray = parseArrayToInt(['1.1', '2.9', '3']); // [1, 2, 3]Rounds a value to a specified number of decimal places.
- v
- Type: 
Number - Required: 
true - Info: The value to round.
 
 - Type: 
 - dec
- Type: 
Number - Required: 
true - Info: The number of decimal places.
 
 - Type: 
 
- Type: 
Number 
let r = roundTo(3.14159, 2); // 3.14Returns a GUID (Globally Unique Identifier) string.
- Type: 
String 
let guid = getGUID();Generates a unique ID of a specified length (max 34).
- len
- Type: 
Number - Required: 
true - Info: The desired length of the unique ID.
 
 - Type: 
 
- Type: 
String 
let uid = getUID(12);Checks if a string is alphanumeric (contains only letters and numbers).
- v
- Type: 
String|Number - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let an1 = isAlphaNumeric('a43'); // true
let an2 = isAlphaNumeric('a43-'); // falseChecks if the input is an array.
- input
- Type: 
* - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let check = isArray([]); // trueChecks if the input is a boolean.
- input
- Type: 
* - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let check = isBool(false); // trueChecks if the input is a boolean. (Alias for isBool)
- input
- Type: 
* - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let check = isBoolean(true); // trueChecks if the input is a valid number.
- n
- Type: 
* - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let check1 = isNumber(42);    // true
let check2 = isNumber('42');  // true
let check3 = isNumber('a');   // falseChecks if the input is a valid number. (Alias for isNumber)
- n
- Type: 
* - Required: 
true - Info: The value to check.
 
 - Type: 
 
- Type: 
Boolean 
let check = isNumeric('42.5'); // trueA class to handle mouse wheel scroll events.
- onScrollUp
- Type: 
Function - Required: 
true - Info: The function to call when the mouse wheel scrolls up.
 
 - Type: 
 - onScrollDown
- Type: 
Function - Required: 
true - Info: The function to call when the mouse wheel scrolls down.
 
 - Type: 
 
function onScrollUpHandler() { console.log('Scrolled Up'); }
function onScrollDownHandler() { console.log('Scrolled Down'); }
new MouseScrollHandler(onScrollUpHandler, onScrollDownHandler);Returns a property from an object by its key (name).
- obj
- Type: 
Object - Required: 
true - Info: The object to search within.
 
 - Type: 
 - key
- Type: 
String - Required: 
true - Info: The name of the property to retrieve.
 
 - Type: 
 
- Type: 
any(the value of the property, orundefinedif not found) 
let myObj = { name: 'AFTC', colors: ['red', 'green'] };
let colorDefinitions = getObjectPropByKey(myObj, 'colors');Truncates a string to a specified length.
- str
- Type: 
String - Required: 
true - Info: The string to cut.
 
 - Type: 
 - len
- Type: 
Number - Required: 
true - Info: The desired length of the returned string.
 
 - Type: 
 
- Type: 
String 
let cutString = cutStringTo('abcdefg', 4); // 'abcd'Escapes HTML special characters in a string.
- str
- Type: 
String - Required: 
true - Info: The string to escape.
 
 - Type: 
 
- Type: 
String 
let newString = escapeHTML('<b>some html</b>'); // '<b>some html</b>'Returns the anchor (hash part) from a URL string.
- url
- Type: 
String - Required: 
true - Info: The URL string.
 
 - Type: 
 
- Type: 
String 
let anchor = getAnchor('https://example.com/page#section2'); // 'section2'Attempts to clean special characters from a string to make it valid JSON.
- s
- Type: 
String - Required: 
true - Info: The JSON string to parse.
 
 - Type: 
 
- Type: 
String 
let newString = getCleanJSONString(oldString);Attempts to get the file extension from a file path string.
- str
- Type: 
String - Required: 
true - Info: The file path or name.
 
 - Type: 
 
- Type: 
String 
let ext = getFileExtension('path/to/my/image.jpeg'); // 'jpeg'Returns the last segment of a URL, split by '/'.
- url
- Type: 
String - Required: 
true - Info: The URL string.
 
 - Type: 
 
- Type: 
String 
let lastSegment = getLastPartOfUrl('https://domain.com/users/profile'); // 'profile'Returns a random string of letters (A-Z, a-z) of a specified length.
- len
- Type: 
Number - Required: 
true - Info: The length of the random string.
 
 - Type: 
 
- Type: 
String 
let randomLetterString = getRandomString(10);Returns the first substring found between start and end markers.
- source
- Type: 
String - Required: 
true - Info: The string to search within.
 
 - Type: 
 - start
- Type: 
String - Required: 
true - Info: The starting marker.
 
 - Type: 
 - end
- Type: 
String - Required: 
true - Info: The ending marker.
 
 - Type: 
 
- Type: 
String 
let str = getStringBetween('<div>hello</div>', '<div>', '</div>'); // 'hello'Returns an array of all substrings found between start and end markers (max 500).
- source
- Type: 
String - Required: 
true - Info: The string to search within.
 
 - Type: 
 - start
- Type: 
String - Required: 
true - Info: The starting marker.
 
 - Type: 
 - end
- Type: 
String - Required: 
true - Info: The ending marker.
 
 - Type: 
 
- Type: 
Array 
let found = getStringBetween2('[a][b][c]', '[', ']'); // ['a', 'b', 'c']Returns the number of words in a string (based on spaces).
- str
- Type: 
String - Required: 
true - Info: The string to count words from.
 
 - Type: 
 
- Type: 
Number 
let wordCount = getWordCount('Hello world, this is a test.'); // 6Checks if a string exists within another string.
- needle
- Type: 
String - Required: 
true - Info: The string to find.
 
 - Type: 
 - haystack
- Type: 
String - Required: 
true - Info: The string to search.
 
 - Type: 
 
- Type: 
Boolean 
let stringFound = inString('world', 'hello world'); // trueChecks if a string exists within another string. (Alias for inString)
- needle
- Type: 
String - Required: 
true - Info: The string to find.
 
 - Type: 
 - haystack
- Type: 
String - Required: 
true - Info: The string to search.
 
 - Type: 
 
- Type: 
Boolean 
let stringFound = isInString('world', 'hello world'); // trueTrims a specified number of characters from the left (start) of a string.
- str
- Type: 
String - Required: 
true - Info: The string to trim.
 
 - Type: 
 - by
- Type: 
Number - Required: 
true - Info: The number of characters to trim.
 
 - Type: 
 
- Type: 
String 
let trimmedString = lTrimBy('__hello', 2); // 'hello'Uses regex to replace all instances of a substring.
- needle
- Type: 
String - Required: 
true - Info: The substring to replace.
 
 - Type: 
 - rep
- Type: 
String - Required: 
true - Info: The replacement string.
 
 - Type: 
 - haystack
- Type: 
String - Required: 
true - Info: The string to perform replacements on.
 
 - Type: 
 
- Type: 
String 
let newString = regExReplaceAll(' ', '_', 'hello world example'); // 'hello_world_example'Removes the filename from a file path, returning the directory path.
- path
- Type: 
String - Required: 
true - Info: The file path.
 
 - Type: 
 
- Type: 
String 
let dirPath = removeFileFromPath('/path/to/file.txt'); // '/path/to/'Uses a split/join method to replace all occurrences of a substring.
- needle
- Type: 
String - Required: 
true - Info: The substring to replace.
 
 - Type: 
 - replace
- Type: 
String - Required: 
true - Info: The replacement string.
 
 - Type: 
 - haystack
- Type: 
String - Required: 
true - Info: The string to perform replacements on.
 
 - Type: 
 
- Type: 
String 
let newString = replaceAll(' ', '_', 'hello world example'); // 'hello_world_example'Replaces double backslashes (\\) in a string with a replacement string.
- str
- Type: 
String - Required: 
true - Info: The string to process.
 
 - Type: 
 - rep
- Type: 
String - Required: 
true - Info: The string to replace 
\\with. 
 - Type: 
 
- Type: 
String 
let processedString = replaceDoubleBackSlash('C:\\Users\\Test', '/'); // 'C:/Users/Test'Replaces double forward slashes (//) in a string with a replacement string.
- str
- Type: 
String - Required: 
true - Info: The string to process.
 
 - Type: 
 - rep
- Type: 
String - Required: 
true - Info: The string to replace 
//with. 
 - Type: 
 
- Type: 
String 
let processedString = replaceDoubleForwardSlash('https://domain.com//path', '/'); // 'https:/domain.com/path'Trims a specified number of characters from the right (end) of a string.
- str
- Type: 
String - Required: 
true - Info: The string to trim.
 
 - Type: 
 - trimBy
- Type: 
Number - Required: 
true - Info: The number of characters to trim.
 
 - Type: 
 
- Type: 
String 
let trimmedString = rTrimBy('hello__', 2); // 'hello'Trims a specified number of characters from the right (end) of a string. (Alias for rTrimBy)
- str
- Type: 
String - Required: 
true - Info: The string to trim.
 
 - Type: 
 - trimBy
- Type: 
Number - Required: 
true - Info: The number of characters to trim.
 
 - Type: 
 
- Type: 
String 
let trimmedString = trimStringBy('hello__', 2); // 'hello'Makes the first letter of a string uppercase.
- s
- Type: 
String - Required: 
true - Info: The string to modify.
 
 - Type: 
 
- Type: 
String 
let ucFirstString = ucFirst('hello'); // 'Hello'A class for detecting swipe gestures (left, right, up, down).
- Configuration Object:
- onSwipeLeft
- Type: 
Function - Required: 
false - Info: Callback for a left swipe.
 
 - Type: 
 - onSwipeRight
- Type: 
Function - Required: 
false - Info: Callback for a right swipe.
 
 - Type: 
 - onSwipeUp
- Type: 
Function - Required: 
false - Info: Callback for an up swipe.
 
 - Type: 
 - onSwipeDown
- Type: 
Function - Required: 
false - Info: Callback for a down swipe.
 
 - Type: 
 - horizontalTolerance
- Type: 
Number - Required: 
false - Default: 
50 - Info: Minimum horizontal distance (in pixels) to trigger a swipe.
 
 - Type: 
 - verticalTolerance
- Type: 
Number - Required: 
false - Default: 
50 - Info: Minimum vertical distance (in pixels) to trigger a swipe.
 
 - Type: 
 - swipeThrottleTimeout
- Type: 
Number - Required: 
false - Default: 
250 - Info: Milliseconds to wait before another swipe can be detected.
 
 - Type: 
 
 - onSwipeLeft
 
new SwipeHandler({
    onSwipeLeft: () => console.log('Swiped Left!'),
    onSwipeRight: () => console.log('Swiped Right!')
});Returns a clean route string from a URL (removes domain, protocol, and query strings).
- url
- Type: 
String - Required: 
false - Info: The URL to parse. If omitted, 
window.location.hrefis used. 
 - Type: 
 
- Type: 
String 
// Assuming URL is 'https://domain.com/users/profile?id=123'
let currentRoute = getRoute(); // '/users/profile'
let usersRoute = getRoute('https://domain.com/users'); // '/users'Attaches a video source to a <video> element and resolves a promise once metadata is loaded. Useful for getting dimensions and duration before playback.
- video
- Type: 
HTMLVideoElement - Required: 
true - Info: The 
<video>element. 
 - Type: 
 - src
- Type: 
String - Required: 
true - Info: The video file source URL.
 
 - Type: 
 
- Type: 
Promise<{width: number, height: number, duration: number}> 
const vid = document.getElementById('my-video');
const vidSrc = './assets/video.mp4';
promiseAttachVideo(vid, vidSrc)
    .then((meta) => {
        console.log('Video ready:', meta); // { width: 1920, height: 1080, duration: 30.5 }
    });Returns a promise that resolves when the video playback has ended.
- video
- Type: 
HTMLVideoElement - Required: 
true - Info: The 
<video>element to monitor. 
 - Type: 
 
- Type: 
Promise<void> 
const vid = document.getElementById('my-video');
vid.play();
promiseVideoEnd(vid)
    .then(() => {
        console.log('Video playback complete');
    });