main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1012 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | 'use strict';
|
---|
| 2 | var $ = require('../internals/export');
|
---|
| 3 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
| 4 | var toIndexedObject = require('../internals/to-indexed-object');
|
---|
| 5 | var toObject = require('../internals/to-object');
|
---|
| 6 | var toString = require('../internals/to-string');
|
---|
| 7 | var lengthOfArrayLike = require('../internals/length-of-array-like');
|
---|
| 8 |
|
---|
| 9 | var push = uncurryThis([].push);
|
---|
| 10 | var join = uncurryThis([].join);
|
---|
| 11 |
|
---|
| 12 | // `String.raw` method
|
---|
| 13 | // https://tc39.es/ecma262/#sec-string.raw
|
---|
| 14 | $({ target: 'String', stat: true }, {
|
---|
| 15 | raw: function raw(template) {
|
---|
| 16 | var rawTemplate = toIndexedObject(toObject(template).raw);
|
---|
| 17 | var literalSegments = lengthOfArrayLike(rawTemplate);
|
---|
| 18 | if (!literalSegments) return '';
|
---|
| 19 | var argumentsLength = arguments.length;
|
---|
| 20 | var elements = [];
|
---|
| 21 | var i = 0;
|
---|
| 22 | while (true) {
|
---|
| 23 | push(elements, toString(rawTemplate[i++]));
|
---|
| 24 | if (i === literalSegments) return join(elements, '');
|
---|
| 25 | if (i < argumentsLength) push(elements, toString(arguments[i]));
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.