es6.string.raw.js 537 B

12345678910111213141516171819
  1. var $export = require('./$.export')
  2. , toIObject = require('./$.to-iobject')
  3. , 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. , len = toLength(tpl.length)
  9. , $$ = arguments
  10. , $$len = $$.length
  11. , res = []
  12. , i = 0;
  13. while(len > i){
  14. res.push(String(tpl[i++]));
  15. if(i < $$len)res.push(String($$[i]));
  16. } return res.join('');
  17. }
  18. });