mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
21 lines
811 B
JavaScript
21 lines
811 B
JavaScript
'use strict';
|
|
var $ = require('../internals/export');
|
|
var flattenIntoArray = require('../internals/flatten-into-array');
|
|
var toObject = require('../internals/to-object');
|
|
var toLength = require('../internals/to-length');
|
|
var toInteger = require('../internals/to-integer');
|
|
var arraySpeciesCreate = require('../internals/array-species-create');
|
|
|
|
// `Array.prototype.flat` method
|
|
// https://tc39.es/ecma262/#sec-array.prototype.flat
|
|
$({ target: 'Array', proto: true }, {
|
|
flat: function flat(/* depthArg = 1 */) {
|
|
var depthArg = arguments.length ? arguments[0] : undefined;
|
|
var O = toObject(this);
|
|
var sourceLen = toLength(O.length);
|
|
var A = arraySpeciesCreate(O, 0);
|
|
A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
|
|
return A;
|
|
}
|
|
});
|