massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / collection-from.js
1 'use strict';
2 // https://tc39.github.io/proposal-setmap-offrom/
3 var bind = require('../internals/function-bind-context');
4 var call = require('../internals/function-call');
5 var aCallable = require('../internals/a-callable');
6 var aConstructor = require('../internals/a-constructor');
7 var iterate = require('../internals/iterate');
8
9 var push = [].push;
10
11 module.exports = function from(source /* , mapFn, thisArg */) {
12   var length = arguments.length;
13   var mapFn = length > 1 ? arguments[1] : undefined;
14   var mapping, array, n, boundFunction;
15   aConstructor(this);
16   mapping = mapFn !== undefined;
17   if (mapping) aCallable(mapFn);
18   if (source == undefined) return new this();
19   array = [];
20   if (mapping) {
21     n = 0;
22     boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined);
23     iterate(source, function (nextItem) {
24       call(push, array, boundFunction(nextItem, n++));
25     });
26   } else {
27     iterate(source, push, { that: array });
28   }
29   return new this(array);
30 };