es6.string.raw.js 519 B

123456789101112131415161718
  1. var $export = require('./_export');
  2. var toIObject = require('./_to-iobject');
  3. var toLength = require('./_to-length');
  4. $export($export.S, 'String', {
  5. // 21.1.2.4 String.raw(callSite, ...substitutions)
  6. raw: function raw(callSite) {
  7. var tpl = toIObject(callSite.raw);
  8. var len = toLength(tpl.length);
  9. var aLen = arguments.length;
  10. var res = [];
  11. var i = 0;
  12. while (len > i) {
  13. res.push(String(tpl[i++]));
  14. if (i < aLen) res.push(String(arguments[i]));
  15. } return res.join('');
  16. }
  17. });