JavaScript function to determine whether a given string is ASCII-safe.

const reNonAscii = /[^\0-\x7F]/; // /\P{ASCII}/u;

/**
 * Determines whether a given string is ASCII-safe, i.e. if it consists of ASCII
 * characters (U+0000 to U+007F) only.
 *
 * Source: https://github.com/mathiasbynens/is-ascii-safe
 *
 * @param {string} str
 * @return {boolean}
 */
const isAsciiSafe = (str) => {
    return !reNonAscii.test(str);
};