|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
|---|
| 4 |
|
|---|
| 5 | var $Object = require('es-object-atoms');
|
|---|
| 6 | var $StringPrototype = GetIntrinsic('%String.prototype%');
|
|---|
| 7 | var $SyntaxError = require('es-errors/syntax');
|
|---|
| 8 | var $TypeError = require('es-errors/type');
|
|---|
| 9 | var setProto = require('set-proto');
|
|---|
| 10 |
|
|---|
| 11 | var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
|
|---|
| 12 |
|
|---|
| 13 | // https://262.ecma-international.org/6.0/#sec-stringcreate
|
|---|
| 14 |
|
|---|
| 15 | module.exports = function StringCreate(value, prototype) {
|
|---|
| 16 | if (typeof value !== 'string') {
|
|---|
| 17 | throw new $TypeError('Assertion failed: `S` must be a String');
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | var S = $Object(value);
|
|---|
| 21 | if (prototype !== $StringPrototype) {
|
|---|
| 22 | if (setProto) {
|
|---|
| 23 | setProto(S, prototype);
|
|---|
| 24 | } else {
|
|---|
| 25 | throw new $SyntaxError('StringCreate: a `proto` argument that is not `String.prototype` is not supported in an environment that does not support setting the [[Prototype]]');
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | var length = value.length;
|
|---|
| 30 | DefinePropertyOrThrow(S, 'length', {
|
|---|
| 31 | '[[Configurable]]': false,
|
|---|
| 32 | '[[Enumerable]]': false,
|
|---|
| 33 | '[[Value]]': length,
|
|---|
| 34 | '[[Writable]]': false
|
|---|
| 35 | });
|
|---|
| 36 |
|
|---|
| 37 | return S;
|
|---|
| 38 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.