string.js 710 B

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = stringTemplate;
  6. var _options = require("./options");
  7. var _parse = _interopRequireDefault(require("./parse"));
  8. var _populate = _interopRequireDefault(require("./populate"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function stringTemplate(formatter, code, opts) {
  11. code = formatter.code(code);
  12. let metadata;
  13. return arg => {
  14. const replacements = (0, _options.normalizeReplacements)(arg);
  15. if (!metadata) metadata = (0, _parse.default)(formatter, code, opts);
  16. return formatter.unwrap((0, _populate.default)(metadata, replacements));
  17. };
  18. }