Sha256: 6c393de72d7c4820c0e3759e79c19679ededddcb0f12f8ab9fa4ee9d3a53fec0
Contents?: true
Size: 1.39 KB
Versions: 208
Compression:
Stored size: 1.39 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 SpeciesConstructor = require('./SpeciesConstructor'); var TypedArrayCreate = require('./TypedArrayCreate'); var getConstructor = require('../helpers/typedArrayConstructors'); // https://262.ecma-international.org/7.0/#typedarray-species-create module.exports = function TypedArraySpeciesCreate(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 defaultConstructor = getConstructor(kind); // step 2 if (typeof defaultConstructor !== 'function') { throw new $SyntaxError('Assertion failed: `constructor` of `exemplar` (' + kind + ') must exist. Please report this!'); } var constructor = SpeciesConstructor(exemplar, defaultConstructor); // step 3 return TypedArrayCreate(constructor, argumentList); // step 4 };
Version data entries
208 entries across 26 versions & 1 rubygems