A robust & optimized `Array.from` polyfill, based on the ECMAScript 6 specification.
npm install array.from[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][npm-badge-png]][package-url]
A spec-compliant Array.from shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.
The Array.from() method creates a new Array instance from an array-like or iterable object.
``bash`
npm install array.from
`js
var from = require('array.from');
var assert = require('assert');
assert.deepEqual(from('abc'), ['a', 'b', 'c']);
`
`js`
var from = require('array.from');
var assert = require('assert');
/ when Array#from is not present /
delete Array.from;
var shimmedFrom = from.shim();
assert.equal(shimmedFrom, from.getPolyfill());
assert.deepEqual(Array.from('foo'), from('foo'));
`js`
var from = require('array.from');
var assert = require('assert');
/ when Array#from is present /
var shimmedFrom = from.shim();
assert.equal(shimmedFrom, Array.from);
assert.deepEqual(Array.from('abc'), from('abc'));
, and run npm test`|  |
|---|
| Mathias Bynens |
This polyfill is available under the MIT license.
[package-url]: https://npmjs.org/package/array.from
[npm-version-svg]: http://versionbadg.es/mathiasbynens/Array.from.svg
[travis-svg]: https://travis-ci.org/mathiasbynens/Array.from.svg
[travis-url]: https://travis-ci.org/mathiasbynens/Array.from
[deps-svg]: https://david-dm.org/mathiasbynens/Array.from.svg
[deps-url]: https://david-dm.org/mathiasbynens/Array.from
[dev-deps-svg]: https://david-dm.org/mathiasbynens/Array.from/dev-status.svg
[dev-deps-url]: https://david-dm.org/mathiasbynens/Array.from#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/array.from.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/array.from.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/array.from.svg
[downloads-url]: http://npm-stat.com/charts.html?package=array.from