.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / array-species-create.js
1 var isObject = require('../internals/is-object');
2 var isArray = require('../internals/is-array');
3 var wellKnownSymbol = require('../internals/well-known-symbol');
4
5 var SPECIES = wellKnownSymbol('species');
6
7 // `ArraySpeciesCreate` abstract operation
8 // https://tc39.es/ecma262/#sec-arrayspeciescreate
9 module.exports = function (originalArray, length) {
10   var C;
11   if (isArray(originalArray)) {
12     C = originalArray.constructor;
13     // cross-realm fallback
14     if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
15     else if (isObject(C)) {
16       C = C[SPECIES];
17       if (C === null) C = undefined;
18     }
19   } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
20 };