Giant blob of minor changes
[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 aFunction = require('../internals/a-function');
4 var bind = require('../internals/function-bind-context');
5 var iterate = require('../internals/iterate');
6
7 module.exports = function from(source /* , mapFn, thisArg */) {
8   var length = arguments.length;
9   var mapFn = length > 1 ? arguments[1] : undefined;
10   var mapping, array, n, boundFunction;
11   aFunction(this);
12   mapping = mapFn !== undefined;
13   if (mapping) aFunction(mapFn);
14   if (source == undefined) return new this();
15   array = [];
16   if (mapping) {
17     n = 0;
18     boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined, 2);
19     iterate(source, function (nextItem) {
20       array.push(boundFunction(nextItem, n++));
21     });
22   } else {
23     iterate(source, array.push, { that: array });
24   }
25   return new this(array);
26 };