es7.array.flat-map.js 740 B

12345678910111213141516171819202122
  1. 'use strict';
  2. // https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap
  3. var $export = require('./_export');
  4. var flattenIntoArray = require('./_flatten-into-array');
  5. var toObject = require('./_to-object');
  6. var toLength = require('./_to-length');
  7. var aFunction = require('./_a-function');
  8. var arraySpeciesCreate = require('./_array-species-create');
  9. $export($export.P, 'Array', {
  10. flatMap: function flatMap(callbackfn /* , thisArg */) {
  11. var O = toObject(this);
  12. var sourceLen, A;
  13. aFunction(callbackfn);
  14. sourceLen = toLength(O.length);
  15. A = arraySpeciesCreate(O, 0);
  16. flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]);
  17. return A;
  18. }
  19. });
  20. require('./_add-to-unscopables')('flatMap');