Files
es5-ext/array/to-array.js
T
Mariusz Nowak 4219c23a74 Reorganize Array.from to follow ECMASCript6 spec
- Array.from always returns copy of input array
- Array.from implements optional mapping functionality
- Array.toArray was introduced as alternative that does not produce copy of an array if it's not needed
- Array#copy was removed, as same now can be achived by Array.from

Array.from doesn't follow ES6 spec in full:
- It doesn't support iterators (which are non existent and cannot be fully shimmed in ES5)
- It doesn't produce array subclasses if it's called in context of such constructors. Array subclasses are not possible in plain ES5 (note: still in many implementations they can be produced with help of `__proto__`, so this part may be subject to changes)
2013-10-01 13:57:59 +02:00

10 lines
176 B
JavaScript

'use strict';
var from = require('./from')
, isArray = Array.isArray;
module.exports = function (arrayLike) {
return isArray(arrayLike) ? arrayLike : from(arrayLike);
};