massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / array-group-by.js
1 var global = require('../internals/global');
2 var bind = require('../internals/function-bind-context');
3 var uncurryThis = require('../internals/function-uncurry-this');
4 var IndexedObject = require('../internals/indexed-object');
5 var toObject = require('../internals/to-object');
6 var toPropertyKey = require('../internals/to-property-key');
7 var lengthOfArrayLike = require('../internals/length-of-array-like');
8 var objectCreate = require('../internals/object-create');
9 var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
10
11 var Array = global.Array;
12 var push = uncurryThis([].push);
13
14 module.exports = function ($this, callbackfn, that, specificConstructor) {
15   var O = toObject($this);
16   var self = IndexedObject(O);
17   var boundFunction = bind(callbackfn, that);
18   var target = objectCreate(null);
19   var length = lengthOfArrayLike(self);
20   var index = 0;
21   var Constructor, key, value;
22   for (;length > index; index++) {
23     value = self[index];
24     key = toPropertyKey(boundFunction(value, index, O));
25     // in some IE10 builds, `hasOwnProperty` returns incorrect result on integer keys
26     // but since it's a `null` prototype object, we can safely use `in`
27     if (key in target) push(target[key], value);
28     else target[key] = [value];
29   }
30   if (specificConstructor) {
31     Constructor = specificConstructor(O);
32     if (Constructor !== Array) {
33       for (key in target) target[key] = arrayFromConstructorAndList(Constructor, target[key]);
34     }
35   } return target;
36 };