ChemPare Documentation - v0.0.0
    Preparing search index...

    Module helpers/utils

    Functions - Suppliers

    tryParseJson

    Tries to parse a JSON string. If it fails, it returns the original string.

    getUserCountry

    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.

    Functions - Helpers

    md5sum

    MD5 hash function that handles various input types. Converts input to string representation before hashing.

    serialize

    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.

    deserialize

    Deserializes a base64 encoded string back to its original form. Reverses the serialize() operation by first base64 decoding, then URI decoding the result.

    sleep

    Creates a promise that resolves after the specified delay. Useful for adding delays in async operations or rate limiting.

    delayAction

    Delays the execution of an action by the specified number of milliseconds. Combines sleep() with a callback function for cleaner async code.

    firstMap

    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.

    mapDefined

    Maps an array of items using a function and filters out any null or undefined results.

    decodeHTMLEntities

    Decodes HTML entities in a string.