Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
726 bytes
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var toIndexedObject = require('../internals/to-indexed-object');
|
---|
3 | var toLength = require('../internals/to-length');
|
---|
4 | var toString = require('../internals/to-string');
|
---|
5 |
|
---|
6 | // `String.raw` method
|
---|
7 | // https://tc39.es/ecma262/#sec-string.raw
|
---|
8 | $({ target: 'String', stat: true }, {
|
---|
9 | raw: function raw(template) {
|
---|
10 | var rawTemplate = toIndexedObject(template.raw);
|
---|
11 | var literalSegments = toLength(rawTemplate.length);
|
---|
12 | var argumentsLength = arguments.length;
|
---|
13 | var elements = [];
|
---|
14 | var i = 0;
|
---|
15 | while (literalSegments > i) {
|
---|
16 | elements.push(toString(rawTemplate[i++]));
|
---|
17 | if (i < argumentsLength) elements.push(toString(arguments[i]));
|
---|
18 | } return elements.join('');
|
---|
19 | }
|
---|
20 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.