source: trip-planner-front/node_modules/core-js/internals/array-group-by.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var bind = require('../internals/function-bind-context');
2var IndexedObject = require('../internals/indexed-object');
3var toObject = require('../internals/to-object');
4var toLength = require('../internals/to-length');
5var toPropertyKey = require('../internals/to-property-key');
6var objectCreate = require('../internals/object-create');
7var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
8
9var push = [].push;
10
11module.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};
Note: See TracBrowser for help on using the repository browser.