wallet-core/node_modules/core-js/modules/$.array-species-create.js

16 lines
541 B
JavaScript
Raw Normal View History

2017-05-03 15:35:00 +02:00
// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
var isObject = require('./$.is-object')
, isArray = require('./$.is-array')
, SPECIES = require('./$.wks')('species');
module.exports = function(original, length){
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 new (C === undefined ? Array : C)(length);
};