/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
- 'use strict';
- // https://tc39.github.io/proposal-setmap-offrom/
- var $export = require('./_export');
- var aFunction = require('./_a-function');
- var ctx = require('./_ctx');
- var forOf = require('./_for-of');
- module.exports = function (COLLECTION) {
- $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
- var mapFn = arguments[1];
- var mapping, A, n, cb;
- aFunction(this);
- mapping = mapFn !== undefined;
- if (mapping) aFunction(mapFn);
- if (source == undefined) return new this();
- A = [];
- if (mapping) {
- n = 0;
- cb = ctx(mapFn, arguments[2], 2);
- forOf(source, false, function (nextItem) {
- A.push(cb(nextItem, n++));
- });
- } else {
- forOf(source, false, A.push, A);
- }
- return new this(A);
- } });
- };