source: imaps-frontend/node_modules/es-abstract/2024/SpeciesConstructor.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 837 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $species = GetIntrinsic('%Symbol.species%', true);
6var $TypeError = require('es-errors/type');
7
8var IsConstructor = require('./IsConstructor');
9var Type = require('./Type');
10
11// https://262.ecma-international.org/6.0/#sec-speciesconstructor
12
13module.exports = function SpeciesConstructor(O, defaultConstructor) {
14 if (Type(O) !== 'Object') {
15 throw new $TypeError('Assertion failed: Type(O) is not Object');
16 }
17 var C = O.constructor;
18 if (typeof C === 'undefined') {
19 return defaultConstructor;
20 }
21 if (Type(C) !== 'Object') {
22 throw new $TypeError('O.constructor is not an Object');
23 }
24 var S = $species ? C[$species] : void 0;
25 if (S == null) {
26 return defaultConstructor;
27 }
28 if (IsConstructor(S)) {
29 return S;
30 }
31 throw new $TypeError('no constructor found');
32};
Note: See TracBrowser for help on using the repository browser.