BVB Source Codes

reactide Show es6.array.from.js Source code

Return Download reactide: download es6.array.from.js Source code - Download reactide Source code - Type:.js
  1. 'use strict';
  2. var ctx            = require('./_ctx')
  3.   , $export        = require('./_export')
  4.   , toObject       = require('./_to-object')
  5.   , call           = require('./_iter-call')
  6.   , isArrayIter    = require('./_is-array-iter')
  7.   , toLength       = require('./_to-length')
  8.   , createProperty = require('./_create-property')
  9.   , getIterFn      = require('./core.get-iterator-method');
  10.  
  11. $export($export.S + $export.F * !require('./_iter-detect')(function(iter){ Array.from(iter); }), 'Array', {
  12.   // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  13.   from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  14.     var O       = toObject(arrayLike)
  15.       , C       = typeof this == 'function' ? this : Array
  16.       , aLen    = arguments.length
  17.       , mapfn   = aLen > 1 ? arguments[1] : undefined
  18.       , mapping = mapfn !== undefined
  19.       , index   = 0
  20.       , iterFn  = getIterFn(O)
  21.       , length, result, step, iterator;
  22.     if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  23.     // if object isn't iterable or it's array with default iterator - use simple case
  24.     if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
  25.       for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
  26.         createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  27.       }
  28.     } else {
  29.       length = toLength(O.length);
  30.       for(result = new C(length); length > index; index++){
  31.         createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  32.       }
  33.     }
  34.     result.length = index;
  35.     return result;
  36.   }
  37. });
  38.  
downloades6.array.from.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top