summaryrefslogtreecommitdiff
path: root/node_modules/core-js/library/modules/_array-species-constructor.js
blob: a715389fd3bebad0c82f8727526e646b10e1379d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var isObject = require('./_is-object')
  , isArray  = require('./_is-array')
  , SPECIES  = require('./_wks')('species');

module.exports = function(original){
  var C;
  if(isArray(original)){
    C = original.constructor;
    // cross-realm fallback
    if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
    if(isObject(C)){
      C = C[SPECIES];
      if(C === null)C = undefined;
    }
  } return C === undefined ? Array : C;
};