source: imaps-frontend/node_modules/es-abstract/2018/SpeciesConstructor.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 839 bytes
RevLine 
[d565449]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');
[79a0317]9
10var isObject = require('../helpers/isObject');
[d565449]11
12// https://262.ecma-international.org/6.0/#sec-speciesconstructor
13
14module.exports = function SpeciesConstructor(O, defaultConstructor) {
[79a0317]15 if (!isObject(O)) {
[d565449]16 throw new $TypeError('Assertion failed: Type(O) is not Object');
17 }
18 var C = O.constructor;
19 if (typeof C === 'undefined') {
20 return defaultConstructor;
21 }
[79a0317]22 if (!isObject(C)) {
[d565449]23 throw new $TypeError('O.constructor is not an Object');
24 }
25 var S = $species ? C[$species] : void 0;
26 if (S == null) {
27 return defaultConstructor;
28 }
29 if (IsConstructor(S)) {
30 return S;
31 }
32 throw new $TypeError('no constructor found');
33};
Note: See TracBrowser for help on using the repository browser.