main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
865 bytes
|
Rev | Line | |
---|
[79a0317] | 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 lengthOfArrayLike = require('../internals/length-of-array-like');
|
---|
| 6 | var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
---|
| 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 = lengthOfArrayLike(O);
|
---|
| 16 | var A = arraySpeciesCreate(O, 0);
|
---|
| 17 | A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
|
---|
| 18 | return A;
|
---|
| 19 | }
|
---|
| 20 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.