species-constructor.js 592 B

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