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