esnext.array.group-by.js 704 B

123456789101112131415161718
  1. 'use strict';
  2. // TODO: Remove from `core-js@4`
  3. var $ = require('../internals/export');
  4. var $group = require('../internals/array-group');
  5. var arrayMethodIsStrict = require('../internals/array-method-is-strict');
  6. var addToUnscopables = require('../internals/add-to-unscopables');
  7. // `Array.prototype.groupBy` method
  8. // https://github.com/tc39/proposal-array-grouping
  9. // https://bugs.webkit.org/show_bug.cgi?id=236541
  10. $({ target: 'Array', proto: true, forced: !arrayMethodIsStrict('groupBy') }, {
  11. groupBy: function groupBy(callbackfn /* , thisArg */) {
  12. var thisArg = arguments.length > 1 ? arguments[1] : undefined;
  13. return $group(this, callbackfn, thisArg);
  14. }
  15. });
  16. addToUnscopables('groupBy');