'use strict';

var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
require('./es6.string.iterator-c2573ffd.js');
var _toObject = require('./_to-object-6de10e57.js');
var _iterDetect = require('./_iter-detect-55a5657a.js');
var core_getIteratorMethod = require('./core.get-iterator-method-f474eacc.js');

var _createProperty = function (object, index, value) {
  if (index in object) _toObject._objectDp.f(object, index, _toObject._propertyDesc(0, value));
  else object[index] = value;
};

_toObject._export(_toObject._export.S + _toObject._export.F * !_iterDetect._iterDetect(function (iter) { Array.from(iter); }), 'Array', {
  // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
    var O = _toObject._toObject(arrayLike);
    var C = typeof this == 'function' ? this : Array;
    var aLen = arguments.length;
    var mapfn = aLen > 1 ? arguments[1] : undefined;
    var mapping = mapfn !== undefined;
    var index = 0;
    var iterFn = core_getIteratorMethod.core_getIteratorMethod(O);
    var length, result, step, iterator;
    if (mapping) mapfn = _toObject._ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
    // if object isn't iterable or it's array with default iterator - use simple case
    if (iterFn != undefined && !(C == Array && _iterDetect._isArrayIter(iterFn))) {
      for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
        _createProperty(result, index, mapping ? _iterDetect._iterCall(iterator, mapfn, [step.value, index], true) : step.value);
      }
    } else {
      length = _toObject._toLength(O.length);
      for (result = new C(length); length > index; index++) {
        _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
      }
    }
    result.length = index;
    return result;
  }
});

var from_1$1 = _toObject._core.Array.from;

var from_1 = _commonjsHelpers.createCommonjsModule(function (module) {
module.exports = { "default": from_1$1, __esModule: true };
});

var _Array$from = _commonjsHelpers.unwrapExports(from_1);

var toConsumableArray = _commonjsHelpers.createCommonjsModule(function (module, exports) {

exports.__esModule = true;



var _from2 = _interopRequireDefault(from_1);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = function (arr) {
  if (Array.isArray(arr)) {
    for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
      arr2[i] = arr[i];
    }

    return arr2;
  } else {
    return (0, _from2.default)(arr);
  }
};
});

var _toConsumableArray = _commonjsHelpers.unwrapExports(toConsumableArray);

exports._Array$from = _Array$from;
exports._toConsumableArray = _toConsumableArray;
