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.
20 lines
679 B
20 lines
679 B
4 years ago
|
var $ = require('../internals/export');
|
||
|
var toIndexedObject = require('../internals/to-indexed-object');
|
||
|
var toLength = require('../internals/to-length');
|
||
|
|
||
|
// `String.raw` method
|
||
|
// https://tc39.github.io/ecma262/#sec-string.raw
|
||
|
$({ target: 'String', stat: true }, {
|
||
|
raw: function raw(template) {
|
||
|
var rawTemplate = toIndexedObject(template.raw);
|
||
|
var literalSegments = toLength(rawTemplate.length);
|
||
|
var argumentsLength = arguments.length;
|
||
|
var elements = [];
|
||
|
var i = 0;
|
||
|
while (literalSegments > i) {
|
||
|
elements.push(String(rawTemplate[i++]));
|
||
|
if (i < argumentsLength) elements.push(String(arguments[i]));
|
||
|
} return elements.join('');
|
||
|
}
|
||
|
});
|