substitute.js 441 B

123456789101112131415
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. function substitute(str, o) {
  4. if (!str || !o) {
  5. return str;
  6. }
  7. return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
  8. if (match.charAt(0) === '\\') {
  9. return match.slice(1);
  10. }
  11. return (o[name] === undefined) ? '' : o[name];
  12. });
  13. }
  14. exports.default = substitute;
  15. //# sourceMappingURL=substitute.js.map