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');
11 var Array = global.Array;
12 var push = uncurryThis([].push);
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);
21 var Constructor, key, value;
22 for (;length > index; 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];
30 if (specificConstructor) {
31 Constructor = specificConstructor(O);
32 if (Constructor !== Array) {
33 for (key in target) target[key] = arrayFromConstructorAndList(Constructor, target[key]);