Gets the user's country from the browser's i18n API. This just splits the locale by the "-" character and returns the second part. This is a simple way to get the country code from the locale.
MD5 hash function that handles various input types. Converts input to string representation before hashing.
Serializes a string to a base64 encoded string. Useful for safely storing strings that may contain special characters. First URI encodes the string, then base64 encodes it.
Deserializes a base64 encoded string back to its original form. Reverses the serialize() operation by first base64 decoding, then URI decoding the result.
Creates a promise that resolves after the specified delay. Useful for adding delays in async operations or rate limiting.
Delays the execution of an action by the specified number of milliseconds. Combines sleep() with a callback function for cleaner async code.
Takes a function and an array of values, applies the function to each value in sequence, and returns the first non-undefined/null result. Useful for trying multiple possible inputs until finding one that produces a valid result.
Maps an array of items using a function and filters out any null or undefined results.
Decodes HTML entities in a string.
Tries to parse a JSON string. If it fails, it returns the original string.