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.

string-cooked.js 1023B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var uncurryThis = require('../internals/function-uncurry-this');
  3. var toIndexedObject = require('../internals/to-indexed-object');
  4. var toString = require('../internals/to-string');
  5. var lengthOfArrayLike = require('../internals/length-of-array-like');
  6. var $TypeError = TypeError;
  7. var push = uncurryThis([].push);
  8. var join = uncurryThis([].join);
  9. // `String.cooked` method
  10. // https://tc39.es/proposal-string-cooked/
  11. module.exports = function cooked(template /* , ...substitutions */) {
  12. var cookedTemplate = toIndexedObject(template);
  13. var literalSegments = lengthOfArrayLike(cookedTemplate);
  14. if (!literalSegments) return '';
  15. var argumentsLength = arguments.length;
  16. var elements = [];
  17. var i = 0;
  18. while (true) {
  19. var nextVal = cookedTemplate[i++];
  20. if (nextVal === undefined) throw new $TypeError('Incorrect template');
  21. push(elements, toString(nextVal));
  22. if (i === literalSegments) return join(elements, '');
  23. if (i < argumentsLength) push(elements, toString(arguments[i]));
  24. }
  25. };