species-constructor.js 518 B

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