UNPKG

@rpearce/flexible-string-replace

Version:

🧶 Safely replace any part of a string with anything. Example: useful for replacing substrings with JSX in React

2 lines (1 loc) • 539 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self)["fsr-umd"]={})}(this,(function(e){"use strict";e.default=function(e,t,n){var f=[],o=0;return n.replace(e,(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var u=e.length,i=e[0],r=e[u-1],p=e[u-2],s=r.slice(o,p),c="function"==typeof t?t.apply(void 0,e):t;return f.push(s,c),o=p+i.length,""})),f.push(n.slice(o)),f},Object.defineProperty(e,"__esModule",{value:!0})}));