You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
745 B
JavaScript
22 lines
745 B
JavaScript
6 years ago
|
'use strict';
|
||
|
// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatten
|
||
|
var $export = require('./_export');
|
||
|
var flattenIntoArray = require('./_flatten-into-array');
|
||
|
var toObject = require('./_to-object');
|
||
|
var toLength = require('./_to-length');
|
||
|
var toInteger = require('./_to-integer');
|
||
|
var arraySpeciesCreate = require('./_array-species-create');
|
||
|
|
||
|
$export($export.P, 'Array', {
|
||
|
flatten: function flatten(/* depthArg = 1 */) {
|
||
|
var depthArg = arguments[0];
|
||
|
var O = toObject(this);
|
||
|
var sourceLen = toLength(O.length);
|
||
|
var A = arraySpeciesCreate(O, 0);
|
||
|
flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
|
||
|
return A;
|
||
|
}
|
||
|
});
|
||
|
|
||
|
require('./_add-to-unscopables')('flatten');
|