You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
464 B
JavaScript
16 lines
464 B
JavaScript
7 years ago
|
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;
|
||
|
};
|