Sha256: 18a70a9279026ea03b811f95a797cde8caf8d77a010880506e0f0b4532a1181d

Contents?: true

Size: 1.09 KB

Versions: 243

Compression:

Stored size: 1.09 KB

Contents

'use strict';

var GetIntrinsic = require('get-intrinsic');

var $Object = GetIntrinsic('%Object%');
var $StringPrototype = GetIntrinsic('%String.prototype%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');

var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
var Type = require('./Type');

var setProto = require('../helpers/setProto');

// https://262.ecma-international.org/6.0/#sec-stringcreate

module.exports = function StringCreate(value, prototype) {
	if (Type(value) !== 'String') {
		throw new $TypeError('Assertion failed: `S` must be a String');
	}

	var S = $Object(value);
	if (prototype !== $StringPrototype) {
		if (setProto) {
			setProto(S, prototype);
		} else {
			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]]');
		}
	}

	var length = value.length;
	DefinePropertyOrThrow(S, 'length', {
		'[[Configurable]]': false,
		'[[Enumerable]]': false,
		'[[Value]]': length,
		'[[Writable]]': false
	});

	return S;
};

Version data entries

243 entries across 27 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/es-abstract/2023/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2019/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2018/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2016/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2020/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2015/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2022/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2017/StringCreate.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2021/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2023/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2015/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2021/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2018/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2022/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2019/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2016/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2020/StringCreate.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2017/StringCreate.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2023/StringCreate.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2015/StringCreate.js