species-constructor.js 509 B

12345678910111213
  1. var anObject = require('../internals/an-object');
  2. var aFunction = require('../internals/a-function');
  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 : aFunction(S);
  11. };