You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
808 B
23 lines
808 B
var global = require('../internals/global'); |
|
var isArray = require('../internals/is-array'); |
|
var isConstructor = require('../internals/is-constructor'); |
|
var isObject = require('../internals/is-object'); |
|
var wellKnownSymbol = require('../internals/well-known-symbol'); |
|
|
|
var SPECIES = wellKnownSymbol('species'); |
|
var Array = global.Array; |
|
|
|
// a part of `ArraySpeciesCreate` abstract operation |
|
// https://tc39.es/ecma262/#sec-arrayspeciescreate |
|
module.exports = function (originalArray) { |
|
var C; |
|
if (isArray(originalArray)) { |
|
C = originalArray.constructor; |
|
// cross-realm fallback |
|
if (isConstructor(C) && (C === Array || isArray(C.prototype))) C = undefined; |
|
else if (isObject(C)) { |
|
C = C[SPECIES]; |
|
if (C === null) C = undefined; |
|
} |
|
} return C === undefined ? Array : C; |
|
};
|
|
|