PageRenderTime 26ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/node_modules/babel-polyfill/node_modules/core-js/library/modules/_set-collection-from.js

https://bitbucket.org/worklabschd/bingle_customer2
JavaScript | 28 lines | 26 code | 1 blank | 1 comment | 5 complexity | 7c8aeae6b99d412750b4212de414f0e1 MD5 | raw file
 1'use strict';
 2// https://tc39.github.io/proposal-setmap-offrom/
 3var $export = require('./_export');
 4var aFunction = require('./_a-function');
 5var ctx = require('./_ctx');
 6var forOf = require('./_for-of');
 7
 8module.exports = function (COLLECTION) {
 9  $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
10    var mapFn = arguments[1];
11    var mapping, A, n, cb;
12    aFunction(this);
13    mapping = mapFn !== undefined;
14    if (mapping) aFunction(mapFn);
15    if (source == undefined) return new this();
16    A = [];
17    if (mapping) {
18      n = 0;
19      cb = ctx(mapFn, arguments[2], 2);
20      forOf(source, false, function (nextItem) {
21        A.push(cb(nextItem, n++));
22      });
23    } else {
24      forOf(source, false, A.push, A);
25    }
26    return new this(A);
27  } });
28};