Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
815 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 aFunction = require('../internals/a-function');
|
---|
| 7 | var arraySpeciesCreate = require('../internals/array-species-create');
|
---|
| 8 |
|
---|
| 9 | // `Array.prototype.flatMap` method
|
---|
| 10 | // https://tc39.es/ecma262/#sec-array.prototype.flatmap
|
---|
| 11 | $({ target: 'Array', proto: true }, {
|
---|
| 12 | flatMap: function flatMap(callbackfn /* , thisArg */) {
|
---|
| 13 | var O = toObject(this);
|
---|
| 14 | var sourceLen = toLength(O.length);
|
---|
| 15 | var A;
|
---|
| 16 | aFunction(callbackfn);
|
---|
| 17 | A = arraySpeciesCreate(O, 0);
|
---|
| 18 | A.length = flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
---|
| 19 | return A;
|
---|
| 20 | }
|
---|
| 21 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.