Sha256: 77338bcac219a920f7356d6f5010f02f0d77705dd31b5fcd0a9943e9aa14062f

Contents?: true

Size: 1.25 KB

Versions: 26

Compression:

Stored size: 1.25 KB

Contents

'use strict';

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

var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');

var whichTypedArray = require('which-typed-array');
var availableTypedArrays = require('available-typed-arrays')();

var IsArray = require('./IsArray');
var TypedArrayCreate = require('./TypedArrayCreate');

var getConstructor = require('../helpers/typedArrayConstructors');

// https://262.ecma-international.org/14.0/#sec-typedarray-create-same-type

module.exports = function TypedArrayCreateSameType(exemplar, argumentList) {
	if (availableTypedArrays.length === 0) {
		throw new $SyntaxError('Assertion failed: Typed Arrays are not supported in this environment');
	}

	var kind = whichTypedArray(exemplar);
	if (!kind) {
		throw new $TypeError('Assertion failed: exemplar must be a TypedArray'); // step 1
	}
	if (!IsArray(argumentList)) {
		throw new $TypeError('Assertion failed: `argumentList` must be a List'); // step 1
	}

	var constructor = getConstructor(kind); // step 2
	if (typeof constructor !== 'function') {
		throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!');
	}

	return TypedArrayCreate(constructor, argumentList); // steps 3 - 6
};

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.28 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.27 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.26 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.25 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.24 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.23 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.22 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.21 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.20 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.19 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.18 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.17 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.16 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.14 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.13 node_modules/es-abstract/2023/TypedArrayCreateSameType.js
immosquare-cleaner-0.1.12 node_modules/es-abstract/2023/TypedArrayCreateSameType.js