UNPKG

606 BJavaScriptView Raw
1'use strict';
2var anObject = require('../internals/an-object');
3var aConstructor = require('../internals/a-constructor');
4var isNullOrUndefined = require('../internals/is-null-or-undefined');
5var wellKnownSymbol = require('../internals/well-known-symbol');
6
7var SPECIES = wellKnownSymbol('species');
8
9// `SpeciesConstructor` abstract operation
10// https://tc39.es/ecma262/#sec-speciesconstructor
11module.exports = function (O, defaultConstructor) {
12 var C = anObject(O).constructor;
13 var S;
14 return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
15};