@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
22 lines (16 loc) • 445 B
JavaScript
/**
*
* @param {string} source
* @param {string} term
* @param {string} extra
* @returns {string}
*/
export function insert_after(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 end = i + term.length;
return source.slice(0, end) + extra + source.slice(end);
}