mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-23 16:13:18 +00:00
21 lines
802 B
JavaScript
21 lines
802 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://github.com/tc39/proposal-flatMap
|
||
|
$({ 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;
|
||
|
}
|
||
|
});
|