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:
811 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var flattenIntoArray = require('../internals/flatten-into-array');
|
---|
4 | var toObject = require('../internals/to-object');
|
---|
5 | var toLength = require('../internals/to-length');
|
---|
6 | var toInteger = require('../internals/to-integer');
|
---|
7 | var arraySpeciesCreate = require('../internals/array-species-create');
|
---|
8 |
|
---|
9 | // `Array.prototype.flat` method
|
---|
10 | // https://tc39.es/ecma262/#sec-array.prototype.flat
|
---|
11 | $({ target: 'Array', proto: true }, {
|
---|
12 | flat: function flat(/* depthArg = 1 */) {
|
---|
13 | var depthArg = arguments.length ? arguments[0] : undefined;
|
---|
14 | var O = toObject(this);
|
---|
15 | var sourceLen = toLength(O.length);
|
---|
16 | var A = arraySpeciesCreate(O, 0);
|
---|
17 | A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
|
---|
18 | return A;
|
---|
19 | }
|
---|
20 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.