Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
683 bytes
|
Line | |
---|
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 | // a part of `ArraySpeciesCreate` abstract operation
|
---|
8 | // https://tc39.es/ecma262/#sec-arrayspeciescreate
|
---|
9 | module.exports = function (originalArray) {
|
---|
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 C === undefined ? Array : C;
|
---|
20 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.