/**
 *
 * @param {string} source
 * @param {string} term
 * @param {string} extra
 * @returns {string}
 */
export function insert_before(source, term, extra) {
    const i = source.indexOf(term);

    if (i === -1) {
        console.warn(`Term '${term}' not found in the source`, source, extra);
        return source;
    }

    const injection_position = i;

    return source.slice(0, injection_position) + extra + source.slice(injection_position);
}
