Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.string.raw.js 1012B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var toIndexedObject = require('../internals/to-indexed-object');
  5. var toObject = require('../internals/to-object');
  6. var toString = require('../internals/to-string');
  7. var lengthOfArrayLike = require('../internals/length-of-array-like');
  8. var push = uncurryThis([].push);
  9. var join = uncurryThis([].join);
  10. // `String.raw` method
  11. // https://tc39.es/ecma262/#sec-string.raw
  12. $({ target: 'String', stat: true }, {
  13. raw: function raw(template) {
  14. var rawTemplate = toIndexedObject(toObject(template).raw);
  15. var literalSegments = lengthOfArrayLike(rawTemplate);
  16. if (!literalSegments) return '';
  17. var argumentsLength = arguments.length;
  18. var elements = [];
  19. var i = 0;
  20. while (true) {
  21. push(elements, toString(rawTemplate[i++]));
  22. if (i === literalSegments) return join(elements, '');
  23. if (i < argumentsLength) push(elements, toString(arguments[i]));
  24. }
  25. }
  26. });