massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.map.group-by.js
index a34c6a01f7dc757cf966dad41b94e60d6e49d8a3..2334a40a42e1da58e7c36bc5e27dc0d917f8c61e 100644 (file)
@@ -1,22 +1,28 @@
 'use strict';
 var $ = require('../internals/export');
+var call = require('../internals/function-call');
+var uncurryThis = require('../internals/function-uncurry-this');
+var aCallable = require('../internals/a-callable');
+var getIterator = require('../internals/get-iterator');
 var iterate = require('../internals/iterate');
-var aFunction = require('../internals/a-function');
+
+var push = uncurryThis([].push);
 
 // `Map.groupBy` method
 // https://github.com/tc39/proposal-collection-methods
 $({ target: 'Map', stat: true }, {
   groupBy: function groupBy(iterable, keyDerivative) {
+    aCallable(keyDerivative);
+    var iterator = getIterator(iterable);
     var newMap = new this();
-    aFunction(keyDerivative);
-    var has = aFunction(newMap.has);
-    var get = aFunction(newMap.get);
-    var set = aFunction(newMap.set);
-    iterate(iterable, function (element) {
+    var has = aCallable(newMap.has);
+    var get = aCallable(newMap.get);
+    var set = aCallable(newMap.set);
+    iterate(iterator, function (element) {
       var derivedKey = keyDerivative(element);
-      if (!has.call(newMap, derivedKey)) set.call(newMap, derivedKey, [element]);
-      else get.call(newMap, derivedKey).push(element);
-    });
+      if (!call(has, newMap, derivedKey)) call(set, newMap, derivedKey, [element]);
+      else push(call(get, newMap, derivedKey), element);
+    }, { IS_ITERATOR: true });
     return newMap;
   }
 });