string.js 565 B

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