function removeAwaitsAndAsyncs(data) {
    const origData = data;
    try {
        if (!data || data.length === 0) {
            return data;
        }

        let isStr = 0;
        let isComment = false;
        const strDelimiters = '\'"`';
        let currentDelimiter = null;
        for (let idx = 0; idx < data.length; idx += 1) {
            if (data.slice(idx, idx + 2) === '*/') {
                isComment = false;
            }

            if (isComment) {
                continue;
            }

            // Check if current character is a string delimiter
            if (strDelimiters.includes(data[idx])) {
                currentDelimiter = strDelimiters.indexOf(data[idx]) + 1;
                if (isStr === 0) {
                    // If not in a string, set state as "in string using specific delimiter"
                    isStr = currentDelimiter;
                } else if (isStr === currentDelimiter && (data[idx - 1] !== '\\' || data[idx - 2] === '\\')) {
                    // If in a string, set state as "not in a string"
                    isStr = 0;
                }
            }

            // If in string, skip current index
            if (isStr !== 0) {
                continue;
            }

            // Skip comments
            if (data.slice(idx, idx + 2) === '/*') {
                isComment = true;
                continue;
            }

            if (data.slice(idx, idx + 6) === 'await ' && idx > 0 && data[idx - 1].split(new RegExp('([a-z]|[A-Z]|[0-9]|_|$)')).length === 1) {
                // Remove await keyword
                data = data.slice(0, idx) + data.slice(idx + 6);
                continue;
            } else if (data.slice(idx, idx + 5) === 'async' && idx > 0 && data[idx - 1].split(new RegExp('([a-z]|[A-Z]|[0-9]|_|$)')).length === 1 && data[idx + 5].split(new RegExp('([a-z]|[A-Z]|[0-9]|_|$)')).length === 1) {
                // Remove async keyword
                data = data.slice(0, idx) + data.slice(idx + 5);
                continue;
            }
        }

        return data;
    } catch (err) {
        return origData;
    }
}
Remove the await and async keyword in a string, except in comments and substrings.
@param {string} data file content.